Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit e361563

Browse files
std::filesystem::u8path 🤔
1 parent 306a315 commit e361563

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

‎OFS-lib/OFS_Util.cpp‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,26 +426,14 @@ std::wstring Util::Utf8ToUtf16(const std::string& str) noexcept
426426

427427
std::filesystem::path Util::PathFromString(const std::string& str) noexcept
428428
{
429-
// this is not very efficient but avoids encoding issues...
430-
std::filesystem::path result;
431-
#if WIN32
432-
auto wideString = Util::Utf8ToUtf16(str);
433-
result = std::filesystem::path(wideString);
434-
#else
435-
result = std::filesystem::path(str);
436-
#endif
429+
auto result = std::filesystem::u8path(str);
437430
result.make_preferred();
438431
return result;
439432
}
440433

441434
void Util::ConcatPathSafe(std::filesystem::path& path, const std::string& element) noexcept
442435
{
443-
// I don't know if this is safe lol
444-
#if WIN32
445-
path /= Util::Utf8ToUtf16(element);
446-
#else
447-
path /= element;
448-
#endif
436+
path /= Util::PathFromString(element);
449437
}
450438

451439
bool Util::SavePNG(const std::string& path, void* buffer, int32_t width, int32_t height, int32_t channels, bool flipVertical) noexcept

‎src/OpenFunscripter.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ void OpenFunscripter::autoBackup() noexcept
15801580
OFS_PROFILE(__FUNCTION__);
15811581
lastBackup = std::chrono::steady_clock::now();
15821582

1583-
auto backupDir = std::filesystem::path(Util::Prefpath("backup"));
1583+
auto backupDir = Util::PathFromString(Util::Prefpath("backup"));
15841584
auto name = Util::Filename(player->getVideoPath());
15851585
name = Util::trim(name); // this needs to be trimmed because trailing spaces
15861586

0 commit comments

Comments
 (0)