feat: move std::filesystem::path related function to independent namespace.

- create FsPathPatch namespace to hold std::filesystem::path related functions.
- add corresponding testbench code for it.
This commit is contained in:
2024-06-15 17:57:33 +08:00
parent e7b13768ec
commit 5481898ad9
7 changed files with 143 additions and 61 deletions

View File

@ -32,22 +32,5 @@ namespace YYCC::IOHelper {
#endif
}
std::filesystem::path UTF8Path(const char* u8_path) {
#if YYCC_OS == YYCC_OS_WINDOWS
// convert path to wchar
std::wstring wpath;
if (!YYCC::EncodingHelper::UTF8ToWchar(u8_path, wpath))
throw std::invalid_argument("Fail to convert given UTF8 string.");
// call microsoft specified fopen which support wchar as argument.
return std::filesystem::path(wpath);
#else
return std::filesystem::path(u8_path);
#endif
}
}