diff --git a/include/fast_io_hosted/filesystem/win9x.h b/include/fast_io_hosted/filesystem/win9x.h index 3d1117b0..9f050511 100644 --- a/include/fast_io_hosted/filesystem/win9x.h +++ b/include/fast_io_hosted/filesystem/win9x.h @@ -5,12 +5,12 @@ namespace fast_io struct win9x_dirent { void *file_struct{}; - ::fast_io::string find_path{}; + ::fast_io::u8string find_path{}; ::fast_io::win9x_dir_handle d_handle{}; file_type d_type{}; ::std::uint_least64_t d_ino{}; - ::fast_io::string filename{}; + ::fast_io::u8string filename{}; ~win9x_dirent() { @@ -28,8 +28,8 @@ inline bool set_win9x_dirent(win9x_dirent &entry, bool start) ::fast_io::win32::win32_find_dataa wfda{}; if (start) { - entry.find_path = ::fast_io::concat_fast_io(entry.d_handle.path, "\\*"); - entry.file_struct = ::fast_io::win32::FindFirstFileA(entry.find_path.c_str(), __builtin_addressof(wfda)); + entry.find_path = ::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(entry.d_handle.path), u8"\\*"); + entry.file_struct = ::fast_io::win32::FindFirstFileA(reinterpret_cast(entry.find_path.c_str()), __builtin_addressof(wfda)); } else { @@ -39,7 +39,7 @@ inline bool set_win9x_dirent(win9x_dirent &entry, bool start) } } - entry.filename = ::fast_io::string{::fast_io::mnp::os_c_str(wfda.cFileName)}; + entry.filename = ::fast_io::u8string{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt_os_c_str(wfda.cFileName))}; if (wfda.dwFileAttributes & 0x400) { @@ -79,9 +79,9 @@ inline bool win9x_dirent_next(win9x_dirent &entry) struct win9x_directory_entry { - using native_char_type = char; + using native_char_type = char8_t; using char_type = char8_t; - win9x_dirent* entry{}; + win9x_dirent *entry{}; template explicit constexpr operator basic_nt_family_io_observer() const noexcept { @@ -103,7 +103,7 @@ inline constexpr win9x_at_entry at(win9x_directory_entry ndet) noexcept return win9x_at_entry{ndet.entry->d_handle}; } -inline constexpr ::fast_io::manipulators::basic_os_c_str_with_known_size +inline constexpr ::fast_io::manipulators::basic_os_c_str_with_known_size native_filename(win9x_directory_entry pioe) noexcept { auto &ent{*pioe.entry}; @@ -129,7 +129,7 @@ u8filename(win9x_directory_entry pioe) noexcept return {reinterpret_cast(ent.filename.c_str()), ent.filename.size()}; } -inline constexpr ::std::uint_least64_t inode_ul64(win9x_directory_entry ) noexcept +inline constexpr ::std::uint_least64_t inode_ul64(win9x_directory_entry) noexcept { return 0; } @@ -142,9 +142,9 @@ inline constexpr file_type type(win9x_directory_entry pioe) noexcept inline bool is_dot(win9x_directory_entry ent) noexcept { ::std::size_t const native_d_namlen{ent.entry->filename.size()}; - char const *native_d_name_ptr{ent.entry->filename.c_str()}; - return ((native_d_namlen == 1 && *native_d_name_ptr == '.') || - (native_d_namlen == 2 && *native_d_name_ptr == '.' && native_d_name_ptr[1] == '.')); + char8_t const *native_d_name_ptr{ent.entry->filename.c_str()}; + return ((native_d_namlen == 1 && *native_d_name_ptr == u8'.') || + (native_d_namlen == 2 && *native_d_name_ptr == u8'.' && native_d_name_ptr[1] == u8'.')); } struct win9x_family_directory_iterator @@ -239,12 +239,12 @@ struct basic_win9x_recursive_directory_iterator using stack_type = StackType; ::fast_io::win9x_dir_handle root_handle{}; void *root_file_struct{}; - win9x_dirent* entry{}; + win9x_dirent *entry{}; stack_type stack; bool finish{}; constexpr basic_win9x_recursive_directory_iterator() = default; - explicit constexpr basic_win9x_recursive_directory_iterator(::fast_io::win9x_dir_handle rh, win9x_dirent* dp) + explicit constexpr basic_win9x_recursive_directory_iterator(::fast_io::win9x_dir_handle rh, win9x_dirent *dp) : root_handle(::std::move(rh)), entry(dp) {} @@ -348,16 +348,17 @@ inline basic_win9x_recursive_directory_iterator &operator++(basic_win if (prdit.entry->d_type == file_type::directory) { ::std::size_t const native_d_namlen{prdit.entry->filename.size()}; - char const *native_d_name_ptr{prdit.entry->filename.c_str()}; - if ((native_d_namlen == 1 && *native_d_name_ptr == '.') || - (native_d_namlen == 2 && *native_d_name_ptr == '.' && native_d_name_ptr[1] == u'.')) + char8_t const *native_d_name_ptr{prdit.entry->filename.c_str()}; + if ((native_d_namlen == 1 && *native_d_name_ptr == u8'.') || + (native_d_namlen == 2 && *native_d_name_ptr == u8'.' && native_d_name_ptr[1] == u8'.')) { continue; } prdit.stack.emplace_back( win9x_dir{win9x_at_entry{prdit.stack.empty() ? prdit.root_handle : prdit.stack.back().fd.handle}, - ::fast_io::manipulators::basic_os_c_str_with_known_size{native_d_name_ptr, native_d_namlen}, - open_mode::directory}, nullptr); + ::fast_io::manipulators::basic_os_c_str_with_known_size{native_d_name_ptr, native_d_namlen}, + open_mode::directory}, + nullptr); } return prdit; } @@ -391,10 +392,10 @@ begin(basic_win9x_recursive_directory_generator &prg) noexcept if (finish && prdit.entry->d_type == file_type::directory) { auto &ent{*prdit.entry}; - char const *native_d_name_ptr{ent.filename.c_str()}; + char8_t const *native_d_name_ptr{ent.filename.c_str()}; ::std::size_t const native_d_namlen{ent.filename.size()}; - if ((native_d_namlen == 1 && *native_d_name_ptr == '.') || - (native_d_namlen == 2 && *native_d_name_ptr == '.' && native_d_name_ptr[1] == '.')) + if ((native_d_namlen == 1 && *native_d_name_ptr == u8'.') || + (native_d_namlen == 2 && *native_d_name_ptr == u8'.' && native_d_name_ptr[1] == u8'.')) { ++prdit; } @@ -402,8 +403,9 @@ begin(basic_win9x_recursive_directory_generator &prg) noexcept { prdit.stack.emplace_back( win9x_dir{win9x_at_entry{prdit.root_handle}, - ::fast_io::manipulators::basic_os_c_str_with_known_size{native_d_name_ptr, native_d_namlen}, - open_mode::directory},nullptr); + ::fast_io::manipulators::basic_os_c_str_with_known_size{native_d_name_ptr, native_d_namlen}, + open_mode::directory}, + nullptr); } } return prdit; @@ -459,25 +461,25 @@ inline win9x_recursive_directory_generator recursive(win9x_at_entry nate) inline auto native_extension(win9x_directory_entry ent) noexcept { auto &et{*ent.entry}; - return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); + return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); } inline auto native_stem(win9x_directory_entry ent) noexcept { auto &et{*ent.entry}; - return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); + return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); } inline auto u8extension(win9x_directory_entry ent) noexcept { auto &et{*ent.entry}; - return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); + return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); } inline auto u8stem(win9x_directory_entry ent) noexcept { auto &et{*ent.entry}; - return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); + return ::fast_io::details::find_dot_and_sep(et.filename.c_str(), et.filename.size()); } #ifndef __CYGWIN__ diff --git a/include/fast_io_hosted/platforms/win32.h b/include/fast_io_hosted/platforms/win32.h index 09481976..d9b7767a 100644 --- a/include/fast_io_hosted/platforms/win32.h +++ b/include/fast_io_hosted/platforms/win32.h @@ -927,7 +927,7 @@ struct struct win9x_dir_handle { void *handle; - ::fast_io::string path; + ::fast_io::u8string path; }; namespace win32::details @@ -980,7 +980,7 @@ inline win9x_dir_handle win9x_create_dir_file_at_fs_dirent_impl(win9x_dir_handle } } - ::fast_io::string str{::fast_io::concat_fast_io(directory_handle.path, "\\", ::fast_io::mnp::code_cvt(::fast_io::mnp::os_c_str_with_known_size(filename_c_str, filename_c_str_len)))}; + ::fast_io::u8string str{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(directory_handle.path), u8"\\", ::fast_io::mnp::code_cvt(::fast_io::mnp::os_c_str_with_known_size(filename_c_str, filename_c_str_len)))}; auto handle{::fast_io::details::win32_create_file_impl(str, ompm)}; return {handle, ::std::move(str)}; } @@ -989,15 +989,15 @@ template requires(::fast_io::constructible_to_os_c_str) inline win9x_dir_handle win9x_create_dir_file_impl(T const &t, open_mode_perms ompm) { - ::fast_io::string path{::fast_io::concat_fast_io(::fast_io::mnp::code_cvt(t))}; + ::fast_io::u8string path{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(t))}; for (auto& c : path) { - if (c == '/') + if (c == u8'/') { - c = '\\'; + c = u8'\\'; } } - if (path.back() == '\\') + if (path.back() == u8'\\') { path.pop_back_unchecked(); } @@ -1146,7 +1146,7 @@ inline win9x_dir_handle win9x_create_dir_file_at_impl(win9x_dir_handle directory } - ::fast_io::string str{::fast_io::concat_fast_io(directory_handle.path, "\\", ::fast_io::mnp::code_cvt(t))}; + ::fast_io::u8string str{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(directory_handle.path), u8"\\", ::fast_io::mnp::code_cvt(t))}; auto handle{::fast_io::details::win32_create_file_impl(str, ompm)}; return {handle, ::std::move(str)}; } @@ -1192,7 +1192,7 @@ inline void *win9x_create_file_at_fs_dirent_impl(win9x_dir_handle directory_hand } } - ::fast_io::string str{::fast_io::concat_fast_io(directory_handle.path, "\\", ::fast_io::mnp::code_cvt(::fast_io::mnp::os_c_str_with_known_size(filename_c_str, filename_c_str_len)))}; + ::fast_io::u8string str{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(directory_handle.path), u8"\\", ::fast_io::mnp::code_cvt(::fast_io::mnp::os_c_str_with_known_size(filename_c_str, filename_c_str_len)))}; auto handle{::fast_io::details::win32_create_file_impl(str, ompm)}; return handle; } @@ -1337,7 +1337,7 @@ inline void *win9x_create_file_at_impl(win9x_dir_handle directory_handle, T cons } } - ::fast_io::string str{::fast_io::concat_fast_io(directory_handle.path, "\\", ::fast_io::mnp::code_cvt(t))}; + ::fast_io::u8string str{::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(directory_handle.path), u8"\\", ::fast_io::mnp::code_cvt(t))}; auto handle{::fast_io::details::win32_create_file_impl(str, ompm)}; return handle; } @@ -1347,7 +1347,7 @@ inline void *win9x_create_file_at_impl(win9x_dir_handle directory_handle, T cons struct win9x_fs_dirent { win9x_dir_handle handle{}; // path - ::fast_io::manipulators::basic_os_c_str_with_known_size filename{}; // file + ::fast_io::manipulators::basic_os_c_str_with_known_size filename{}; // file }; struct win9x_at_entry @@ -1386,7 +1386,7 @@ class win9x_dir_io_observer { public: using native_handle_type = win9x_dir_handle; - using char_type = char; + using char_type = char8_t; using input_char_type = char_type; using output_char_type = char_type; native_handle_type handle{}; diff --git a/include/fast_io_hosted/process/win32.h b/include/fast_io_hosted/process/win32.h index 74927cbf..d6690fca 100644 --- a/include/fast_io_hosted/process/win32.h +++ b/include/fast_io_hosted/process/win32.h @@ -230,13 +230,13 @@ inline win32_user_process_information win32_process_create_impl(void *__restrict auto address_begin{pszFilename}; // change nt path to dos path - auto k32_module{::fast_io::win32::GetModuleHandleA("Kernel32.dll")}; + auto k32_module{::fast_io::win32::GetModuleHandleA(reinterpret_cast(u8"Kernel32.dll"))}; if (k32_module) { using QueryDosDeviceA_t = ::std::uint_least32_t (*)(char const *, char *, ::std::uint_least32_t) noexcept; // win95 may not have this function, need check (?) - auto QueryDosDeviceA_p{reinterpret_cast(::fast_io::win32::GetProcAddress(k32_module, "QueryDosDeviceA"))}; + auto QueryDosDeviceA_p{reinterpret_cast(::fast_io::win32::GetProcAddress(k32_module, reinterpret_cast(u8"QueryDosDeviceA")))}; if (QueryDosDeviceA_p) { if (pszFilename[0] == '\\')