trunk/src/osd/windows/winutf8.cpp
| r255128 | r255129 | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | //============================================================ |
| 37 | | // win_get_module_file_name_utf8 |
| 38 | | //============================================================ |
| 39 | | |
| 40 | | DWORD 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 | | |
| 63 | | BOOL 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 | | |
| 83 | | BOOL 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 | | |
| 113 | | BOOL 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 | | //============================================================ |
| 140 | 37 | // win_message_box_utf8 |
| 141 | 38 | //============================================================ |
| 142 | 39 | |
| r255128 | r255129 | |
| 188 | 85 | goto done; |
| 189 | 86 | } |
| 190 | 87 | |
| 88 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 191 | 89 | 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 |
| 192 | 94 | |
| 193 | 95 | done: |
| 194 | 96 | if (t_text) |
| r255128 | r255129 | |
| 210 | 112 | |
| 211 | 113 | t_buffer[0] = '\0'; |
| 212 | 114 | |
| 115 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 213 | 116 | // invoke the core Win32 API |
| 214 | 117 | 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 |
| 215 | 122 | |
| 216 | 123 | utf8_buffer = utf8_from_tstring(t_buffer); |
| 217 | 124 | if (!utf8_buffer) |
trunk/src/osd/windows/winutf8.h
| r255128 | r255129 | |
| 13 | 13 | |
| 14 | 14 | // wrappers for kernel32.dll |
| 15 | 15 | void win_output_debug_string_utf8(const char *string); |
| 16 | | DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size); |
| 17 | | BOOL win_set_file_attributes_utf8(const char* filename, DWORD fileattributes); |
| 18 | | BOOL win_copy_file_utf8(const char* existingfilename, const char* newfilename, BOOL failifexists); |
| 19 | | BOOL win_move_file_utf8(const char* existingfilename, const char* newfilename); |
| 20 | 16 | |
| 21 | 17 | // wrappers for user32.dll |
| 22 | 18 | int win_message_box_utf8(HWND window, const char *text, const char *caption, UINT type); |