Previous 199869 Revisions Next

r46617 Wednesday 23rd March, 2016 at 16:44:30 UTC by Brad Hughes
Removing unused functions from winutf8.cpp. Also adding UWP implementations for Set/GetWindowText.
[src/osd/windows]winutf8.cpp winutf8.h

trunk/src/osd/windows/winutf8.cpp
r255128r255129
3434
3535
3636//============================================================
37//  win_get_module_file_name_utf8
38//============================================================
39
40DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size)
41{
42   TCHAR t_filename[MAX_PATH];
43   char *utf8_filename;
44
45   if (GetModuleFileName(module, t_filename, ARRAY_LENGTH(t_filename)) == 0)
46      return 0;
47
48   utf8_filename = utf8_from_tstring(t_filename);
49   if (!utf8_filename)
50      return 0;
51
52   size = (DWORD) snprintf(filename, size, "%s", utf8_filename);
53   osd_free(utf8_filename);
54   return size;
55}
56
57
58
59//============================================================
60//  win_set_file_attributes_utf8
61//============================================================
62
63BOOL win_set_file_attributes_utf8(const char* filename, DWORD fileattributes)
64{
65   BOOL result = FALSE;
66   TCHAR* t_filename = tstring_from_utf8(filename);
67   if( !t_filename )
68      return result;
69
70   result = SetFileAttributes(t_filename, fileattributes);
71
72   osd_free(t_filename);
73
74   return result;
75}
76
77
78
79//============================================================
80//  win_copy_file_utf8
81//============================================================
82
83BOOL win_copy_file_utf8(const char* existingfilename, const char* newfilename, BOOL failifexists)
84{
85   TCHAR* t_existingfilename;
86   TCHAR* t_newfilename;
87   BOOL result = FALSE;
88
89   t_existingfilename = tstring_from_utf8(existingfilename);
90   if( !t_existingfilename )
91      return result;
92
93   t_newfilename = tstring_from_utf8(newfilename);
94   if( !t_newfilename ) {
95      osd_free(t_existingfilename);
96      return result;
97   }
98
99   result = CopyFile(t_existingfilename, t_newfilename, failifexists);
100
101   osd_free(t_newfilename);
102   osd_free(t_existingfilename);
103
104   return result;
105}
106
107
108
109//============================================================
110//  win_move_file_utf8
111//============================================================
112
113BOOL win_move_file_utf8(const char* existingfilename, const char* newfilename)
114{
115   TCHAR* t_existingfilename;
116   TCHAR* t_newfilename;
117   BOOL result = FALSE;
118
119   t_existingfilename = tstring_from_utf8(existingfilename);
120   if( !t_existingfilename )
121      return result;
122
123   t_newfilename = tstring_from_utf8(newfilename);
124   if( !t_newfilename ) {
125      free(t_existingfilename);
126      return result;
127   }
128
129   result = MoveFile(t_existingfilename, t_newfilename);
130
131   osd_free(t_newfilename);
132   osd_free(t_existingfilename);
133
134   return result;
135}
136
137
138
139//============================================================
14037//  win_message_box_utf8
14138//============================================================
14239
r255128r255129
18885         goto done;
18986   }
19087
88#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
19189   result = SetWindowText(window, t_text);
90#else
91   Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->Title = ref new Platform::String(t_text);
92   result = TRUE;
93#endif
19294
19395done:
19496   if (t_text)
r255128r255129
210112
211113   t_buffer[0] = '\0';
212114
115#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
213116   // invoke the core Win32 API
214117   GetWindowText(window, t_buffer, ARRAY_LENGTH(t_buffer));
118#else
119   auto title = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->Title;
120   wcsncpy(t_buffer, title->Data(), ARRAY_LENGTH(t_buffer));
121#endif
215122
216123   utf8_buffer = utf8_from_tstring(t_buffer);
217124   if (!utf8_buffer)
trunk/src/osd/windows/winutf8.h
r255128r255129
1313
1414// wrappers for kernel32.dll
1515void win_output_debug_string_utf8(const char *string);
16DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size);
17BOOL win_set_file_attributes_utf8(const char* filename, DWORD fileattributes);
18BOOL win_copy_file_utf8(const char* existingfilename, const char* newfilename, BOOL failifexists);
19BOOL win_move_file_utf8(const char* existingfilename, const char* newfilename);
2016
2117// wrappers for user32.dll
2218int win_message_box_utf8(HWND window, const char *text, const char *caption, UINT type);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team