1717// For Windows systems
1818#include < direct.h>
1919#include < windows.h>
20- #include < locale>
21- #include < codecvt>
2220#elif defined(__APPLE__)
2321// For macOS systems
2422#include < mach-o/dyld.h>
@@ -46,10 +44,7 @@ namespace logit {
4644
4745 inline std::string get_exec_dir () { return " ./" ; }
4846
49- inline std::vector<std::string> get_list_files (const std::string&) {
50- std::cerr << " get_list_files is not supported under Emscripten" << std::endl;
51- return {};
52- }
47+ inline std::vector<std::string> get_list_files (const std::string&) = delete;
5348
5449 inline std::string get_file_name (const std::string& file_path) {
5550 size_t pos = file_path.find_last_of (" /\\ " );
@@ -61,9 +56,7 @@ namespace logit {
6156 return file_path;
6257 }
6358
64- inline void create_directories (const std::string&) {
65- std::cerr << " create_directories is not supported under Emscripten" << std::endl;
66- }
59+ inline void create_directories (const std::string&) = delete;
6760
6861 inline bool is_file (const std::string& path) {
6962 size_t dot_pos = path.find_last_of (' .' );
@@ -102,8 +95,7 @@ namespace logit {
10295 }
10396
10497 // Convert from std::wstring (UTF-16) to std::string (UTF-8)
105- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t >> converter;
106- return converter.to_bytes (exe_path);
98+ return wstring_to_utf8 (exe_path);
10799# elif defined(__APPLE__)
108100 uint32_t size = 0 ;
109101 _NSGetExecutablePath (nullptr , &size);
@@ -149,7 +141,6 @@ namespace logit {
149141 std::vector<std::string> list_files;
150142# ifdef _WIN32
151143 // Use wide versions of functions to correctly handle non-ASCII characters.
152- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t >> converter;
153144 std::wstring wsearch_path;
154145
155146 // If the path is empty, use the current directory.
@@ -158,7 +149,7 @@ namespace logit {
158149 GetCurrentDirectoryW (MAX_PATH, buffer);
159150 wsearch_path = buffer;
160151 } else {
161- wsearch_path = converter. from_bytes (path);
152+ wsearch_path = utf8_to_wstring (path);
162153 }
163154
164155 // Ensure there is a trailing separator.
@@ -182,11 +173,11 @@ namespace logit {
182173
183174 if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
184175 // Recursively process subdirectories.
185- std::vector<std::string> sub_files = get_list_files (converter. to_bytes (wfull_path));
176+ std::vector<std::string> sub_files = get_list_files (wstring_to_utf8 (wfull_path));
186177 list_files.insert (list_files.end (), sub_files.begin (), sub_files.end ());
187178 } else {
188179 // Add the found file.
189- list_files.push_back (converter. to_bytes (wfull_path));
180+ list_files.push_back (wstring_to_utf8 (wfull_path));
190181 }
191182 } while (FindNextFileW (hFind, &fd));
192183 FindClose (hFind);
@@ -267,8 +258,7 @@ namespace logit {
267258 void create_directories (const std::string& path) {
268259# ifdef _WIN32
269260 // Convert UTF-8 string to wide string for Windows
270- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t >> converter;
271- std::wstring wide_path = converter.from_bytes (path);
261+ std::wstring wide_path = utf8_to_wstring (path);
272262 std::filesystem::path dir (wide_path);
273263# else
274264 std::filesystem::path dir = std::filesystem::u8path (path);
0 commit comments