early-access version 1681

This commit is contained in:
pineappleEA
2021-05-14 06:07:23 +02:00
parent b195744abc
commit e076db528d
12 changed files with 198 additions and 281 deletions

View File

@@ -26,51 +26,6 @@ namespace fs = std::filesystem;
namespace {
/**
* Converts the file access mode and file type enums to a file access mode string.
*
* @param mode File access mode
* @param type File type
*
* @returns A pointer to a string representing the file access mode.
*/
[[nodiscard]] constexpr const char* AccessModeToStr(FileAccessMode mode, FileType type) {
switch (type) {
case FileType::BinaryFile:
switch (mode) {
case FileAccessMode::Read:
return "rb";
case FileAccessMode::Write:
return "wb";
case FileAccessMode::Append:
return "ab";
case FileAccessMode::ReadWrite:
return "r+b";
case FileAccessMode::ReadAppend:
return "a+b";
default:
return "";
}
case FileType::TextFile:
switch (mode) {
case FileAccessMode::Read:
return "r";
case FileAccessMode::Write:
return "w";
case FileAccessMode::Append:
return "a";
case FileAccessMode::ReadWrite:
return "r+";
case FileAccessMode::ReadAppend:
return "a+";
default:
return "";
}
default:
return "";
}
}
#ifdef _WIN32
/**
@@ -95,9 +50,8 @@ namespace {
return L"r+b";
case FileAccessMode::ReadAppend:
return L"a+b";
default:
return L"";
}
break;
case FileType::TextFile:
switch (mode) {
case FileAccessMode::Read:
@@ -110,12 +64,11 @@ namespace {
return L"r+";
case FileAccessMode::ReadAppend:
return L"a+";
default:
return L"";
}
default:
return L"";
break;
}
return L"";
}
/**
@@ -139,6 +92,51 @@ namespace {
}
}
#else
/**
* Converts the file access mode and file type enums to a file access mode string.
*
* @param mode File access mode
* @param type File type
*
* @returns A pointer to a string representing the file access mode.
*/
[[nodiscard]] constexpr const char* AccessModeToStr(FileAccessMode mode, FileType type) {
switch (type) {
case FileType::BinaryFile:
switch (mode) {
case FileAccessMode::Read:
return "rb";
case FileAccessMode::Write:
return "wb";
case FileAccessMode::Append:
return "ab";
case FileAccessMode::ReadWrite:
return "r+b";
case FileAccessMode::ReadAppend:
return "a+b";
}
break;
case FileType::TextFile:
switch (mode) {
case FileAccessMode::Read:
return "r";
case FileAccessMode::Write:
return "w";
case FileAccessMode::Append:
return "a";
case FileAccessMode::ReadWrite:
return "r+";
case FileAccessMode::ReadAppend:
return "a+";
}
break;
}
return "";
}
#endif
/**
@@ -172,8 +170,8 @@ std::string ReadStringFromFile(const std::filesystem::path& path, FileType type)
return io_file.ReadString(io_file.GetSize());
}
std::size_t WriteStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string) {
size_t WriteStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string) {
if (!IsFile(path)) {
return 0;
}
@@ -183,8 +181,8 @@ std::size_t WriteStringToFile(const std::filesystem::path& path, FileType type,
return io_file.WriteString(string);
}
std::size_t AppendStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string) {
size_t AppendStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string) {
if (!Exists(path)) {
return WriteStringToFile(path, type, string);
@@ -297,19 +295,16 @@ bool IOFile::IsOpen() const {
return file != nullptr;
}
std::string IOFile::ReadString(std::size_t length) const {
std::string IOFile::ReadString(size_t length) const {
std::vector<char> string_buffer(length);
const auto chars_read = ReadSpan<char>(string_buffer);
const auto string_size = chars_read != length ? chars_read : length;
if (chars_read != length) {
return std::string{string_buffer.data(), chars_read};
}
return std::string{string_buffer.data(), string_buffer.size()};
return std::string{string_buffer.data(), string_size};
}
std::size_t IOFile::WriteString(std::span<const char> string) const {
size_t IOFile::WriteString(std::span<const char> string) const {
return WriteSpan(string);
}

View File

@@ -18,16 +18,13 @@
namespace Common::FS {
enum class SeekOrigin {
/// Seeks from the start of the file.
SetOrigin,
/// Seeks from the current file pointer position.
CurrentPosition,
/// Seeks from the end of the file.
End,
SetOrigin, // Seeks from the start of the file.
CurrentPosition, // Seeks from the current file pointer position.
End, // Seeks from the end of the file.
};
/**
* Opens a file stream at path with a specified open mode.
* Opens a file stream at path with the specified open mode.
*
* @param file_stream Reference to file stream
* @param path Filesystem path
@@ -43,8 +40,7 @@ void OpenFileStream(FileStream& file_stream, const std::filesystem::path& path,
template <typename FileStream, typename Path>
void OpenFileStream(FileStream& file_stream, const Path& path, std::ios_base::openmode open_mode) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
file_stream.open(ToU8String(path), open_mode);
} else {
file_stream.open(std::filesystem::path{path}, open_mode);
@@ -68,8 +64,7 @@ void OpenFileStream(FileStream& file_stream, const Path& path, std::ios_base::op
template <typename Path>
[[nodiscard]] std::string ReadStringFromFile(const Path& path, FileType type) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return ReadStringFromFile(ToU8String(path), type);
} else {
return ReadStringFromFile(std::filesystem::path{path}, type);
@@ -88,16 +83,14 @@ template <typename Path>
*
* @returns Number of characters successfully written.
*/
[[nodiscard]] std::size_t WriteStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string);
[[nodiscard]] size_t WriteStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string);
#ifdef _WIN32
template <typename Path>
[[nodiscard]] std::size_t WriteStringToFile(const Path& path, FileType type,
std::string_view string) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
[[nodiscard]] size_t WriteStringToFile(const Path& path, FileType type, std::string_view string) {
if constexpr (IsChar<typename Path::value_type>) {
return WriteStringToFile(ToU8String(path), type, string);
} else {
return WriteStringToFile(std::filesystem::path{path}, type, string);
@@ -116,16 +109,14 @@ template <typename Path>
*
* @returns Number of characters successfully written.
*/
[[nodiscard]] std::size_t AppendStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string);
[[nodiscard]] size_t AppendStringToFile(const std::filesystem::path& path, FileType type,
std::string_view string);
#ifdef _WIN32
template <typename Path>
[[nodiscard]] std::size_t AppendStringToFile(const Path& path, FileType type,
std::string_view string) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
[[nodiscard]] size_t AppendStringToFile(const Path& path, FileType type, std::string_view string) {
if constexpr (IsChar<typename Path::value_type>) {
return AppendStringToFile(ToU8String(path), type, string);
} else {
return AppendStringToFile(std::filesystem::path{path}, type, string);
@@ -186,7 +177,7 @@ public:
[[nodiscard]] FileType GetType() const;
/**
* Opens a file at path with a specified file access mode.
* Opens a file at path with the specified file access mode.
* This function behaves differently depending on the FileAccessMode.
* These behaviors are documented in each enum value of FileAccessMode.
*
@@ -215,11 +206,11 @@ public:
#endif
/// Closes a file if it is opened.
/// Closes the file if it is opened.
void Close();
/**
* Returns whether the file is open.
* Checks whether the file is open.
* Use this to check whether the calls to Open() or Close() succeeded.
*
* @returns True if the file is open, false otherwise.
@@ -241,7 +232,7 @@ public:
* @returns Count of T::value_type data or objects successfully read.
*/
template <typename T>
[[nodiscard]] std::size_t Read(T& data) const {
[[nodiscard]] size_t Read(T& data) const {
if constexpr (IsSTLContainer<T>) {
using ContiguousType = typename T::value_type;
static_assert(std::is_trivially_copyable_v<ContiguousType>,
@@ -267,7 +258,7 @@ public:
* @returns Count of T::value_type data or objects successfully written.
*/
template <typename T>
[[nodiscard]] std::size_t Write(const T& data) const {
[[nodiscard]] size_t Write(const T& data) const {
if constexpr (IsSTLContainer<T>) {
using ContiguousType = typename T::value_type;
static_assert(std::is_trivially_copyable_v<ContiguousType>,
@@ -296,7 +287,7 @@ public:
* @returns Count of T data successfully read.
*/
template <typename T>
[[nodiscard]] std::size_t ReadSpan(std::span<T> data) const {
[[nodiscard]] size_t ReadSpan(std::span<T> data) const {
static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
if (!IsOpen()) {
@@ -322,7 +313,7 @@ public:
* @returns Count of T data successfully written.
*/
template <typename T>
[[nodiscard]] std::size_t WriteSpan(std::span<const T> data) const {
[[nodiscard]] size_t WriteSpan(std::span<const T> data) const {
static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
if (!IsOpen()) {
@@ -397,7 +388,7 @@ public:
*
* @returns A string read from the file.
*/
[[nodiscard]] std::string ReadString(std::size_t length) const;
[[nodiscard]] std::string ReadString(size_t length) const;
/**
* Specialized function to write a string to a file sequentially.
@@ -408,7 +399,7 @@ public:
*
* @returns Number of characters successfully written.
*/
[[nodiscard]] std::size_t WriteString(std::span<const char> string) const;
[[nodiscard]] size_t WriteString(std::span<const char> string) const;
/**
* Flushes any unwritten buffered data into the file.
@@ -442,7 +433,7 @@ public:
[[nodiscard]] u64 GetSize() const;
/**
* Moves the current position of the file pointer with a specified offset and seek origin.
* Moves the current position of the file pointer with the specified offset and seek origin.
*
* @param offset Offset from seek origin
* @param origin Seek origin
@@ -460,9 +451,7 @@ public:
private:
std::filesystem::path file_path;
FileAccessMode file_access_mode;
FileType file_type;
std::FILE* file = nullptr;

View File

@@ -17,7 +17,7 @@ class IOFile;
// File Operations
/**
* Creates a new file at path with a specified size.
* Creates a new file at path with the specified size.
*
* Failures occur when:
* - Input path is not valid
@@ -36,8 +36,7 @@ class IOFile;
template <typename Path>
[[nodiscard]] bool NewFile(const Path& path, u64 size = 0) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return NewFile(ToU8String(path), size);
} else {
return NewFile(std::filesystem::path{path}, size);
@@ -64,8 +63,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool RemoveFile(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return RemoveFile(ToU8String(path));
} else {
return RemoveFile(std::filesystem::path{path});
@@ -112,7 +110,7 @@ template <typename Path1, typename Path2>
#endif
/**
* Opens a file at path with a specified file access mode.
* Opens a file at path with the specified file access mode.
* This function behaves differently depending on the FileAccessMode.
* These behaviors are documented in each enum value of FileAccessMode.
*
@@ -139,8 +137,7 @@ template <typename Path>
[[nodiscard]] std::shared_ptr<IOFile> FileOpen(const Path& path, FileAccessMode mode,
FileType type = FileType::BinaryFile,
FileShareFlag flag = FileShareFlag::ShareReadOnly) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return FileOpen(ToU8String(path), mode, type, flag);
} else {
return FileOpen(std::filesystem::path{path}, mode, type, flag);
@@ -172,8 +169,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool CreateDir(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return CreateDir(ToU8String(path));
} else {
return CreateDir(std::filesystem::path{path});
@@ -203,8 +199,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool CreateDirs(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return CreateDirs(ToU8String(path));
} else {
return CreateDirs(std::filesystem::path{path});
@@ -227,8 +222,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool CreateParentDir(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return CreateParentDir(ToU8String(path));
} else {
return CreateParentDir(std::filesystem::path{path});
@@ -251,8 +245,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool CreateParentDirs(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return CreateParentDirs(ToU8String(path));
} else {
return CreateParentDirs(std::filesystem::path{path});
@@ -280,8 +273,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool RemoveDir(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return RemoveDir(ToU8String(path));
} else {
return RemoveDir(std::filesystem::path{path});
@@ -308,8 +300,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool RemoveDirRecursively(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return RemoveDirRecursively(ToU8String(path));
} else {
return RemoveDirRecursively(std::filesystem::path{path});
@@ -336,8 +327,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool RemoveDirContentsRecursively(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return RemoveDirContentsRecursively(ToU8String(path));
} else {
return RemoveDirContentsRecursively(std::filesystem::path{path});
@@ -407,8 +397,7 @@ void IterateDirEntries(const std::filesystem::path& path, const DirEntryCallable
template <typename Path>
void IterateDirEntries(const Path& path, const DirEntryCallable& callback,
DirEntryFilter filter = DirEntryFilter::All) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
IterateDirEntries(ToU8String(path), callback, filter);
} else {
IterateDirEntries(std::filesystem::path{path}, callback, filter);
@@ -442,8 +431,7 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
template <typename Path>
void IterateDirEntriesRecursively(const Path& path, const DirEntryCallable& callback,
DirEntryFilter filter = DirEntryFilter::All) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
IterateDirEntriesRecursively(ToU8String(path), callback, filter);
} else {
IterateDirEntriesRecursively(std::filesystem::path{path}, callback, filter);
@@ -467,8 +455,7 @@ void IterateDirEntriesRecursively(const Path& path, const DirEntryCallable& call
template <typename Path>
[[nodiscard]] bool Exists(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return Exists(ToU8String(path));
} else {
return Exists(std::filesystem::path{path});
@@ -490,8 +477,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool IsFile(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return IsFile(ToU8String(path));
} else {
return IsFile(std::filesystem::path{path});
@@ -513,8 +499,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool IsDir(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return IsDir(ToU8String(path));
} else {
return IsDir(std::filesystem::path{path});
@@ -541,8 +526,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] bool SetCurrentDir(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return SetCurrentDir(ToU8String(path));
} else {
return SetCurrentDir(std::filesystem::path{path});
@@ -564,8 +548,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] std::filesystem::file_type GetEntryType(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return GetEntryType(ToU8String(path));
} else {
return GetEntryType(std::filesystem::path{path});
@@ -587,8 +570,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] u64 GetSize(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return GetSize(ToU8String(path));
} else {
return GetSize(std::filesystem::path{path});
@@ -610,8 +592,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] u64 GetFreeSpaceSize(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return GetFreeSpaceSize(ToU8String(path));
} else {
return GetFreeSpaceSize(std::filesystem::path{path});
@@ -633,8 +614,7 @@ template <typename Path>
template <typename Path>
[[nodiscard]] u64 GetTotalSpaceSize(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return GetTotalSpaceSize(ToU8String(path));
} else {
return GetTotalSpaceSize(std::filesystem::path{path});

View File

@@ -47,14 +47,10 @@ enum class FileType {
};
enum class FileShareFlag {
/// Provides exclusive access to the file.
ShareNone,
/// Provides read only shared access to the file.
ShareReadOnly,
/// Provides write only shared access to the file.
ShareWriteOnly,
/// Provides read and write shared access to the file.
ShareReadWrite,
ShareNone, // Provides exclusive access to the file.
ShareReadOnly, // Provides read only shared access to the file.
ShareWriteOnly, // Provides write only shared access to the file.
ShareReadWrite, // Provides read and write shared access to the file.
};
enum class DirEntryFilter {

View File

@@ -51,12 +51,6 @@ namespace Common::FS {
namespace fs = std::filesystem;
namespace {
constexpr std::array<char8_t, 7> INVALID_CHARS{u':', u'*', u'?', u'"', u'<', u'>', u'|'};
}
/**
* The PathManagerImpl is a singleton allowing to manage the mapping of
* YuzuPath enums to real filesystem paths.
@@ -167,31 +161,20 @@ bool ValidatePath(const fs::path& path) {
#endif
for (const auto path_char : path.relative_path().u8string()) {
for (const auto invalid_char : INVALID_CHARS) {
if (path_char == invalid_char) {
LOG_ERROR(Common_Filesystem, "Input path contains invalid characters, path={}",
PathToUTF8String(path));
return false;
}
}
}
return true;
}
fs::path ConcatPath(const fs::path& first, const fs::path& second) {
const bool second_has_dir_sep = IsDirSeparator(second.u8string().front());
if (second_has_dir_sep) {
fs::path concat_path = first;
concat_path += second;
return concat_path.lexically_normal();
if (!second_has_dir_sep) {
return (first / second).lexically_normal();
}
return (first / second).lexically_normal();
fs::path concat_path = first;
concat_path += second;
return concat_path.lexically_normal();
}
fs::path ConcatPathSafe(const fs::path& base, const fs::path& offset) {
@@ -289,14 +272,10 @@ fs::path GetAppDataRoamingDirectory() {
#else
fs::path GetHomeDirectory() {
fs::path home_path;
const char* home_env_var = getenv("HOME");
if (home_env_var) {
home_path = fs::path{home_env_var};
return home_path;
return fs::path{home_env_var};
}
LOG_INFO(Common_Filesystem,
@@ -305,35 +284,30 @@ fs::path GetHomeDirectory() {
const auto* pw = getpwuid(getuid());
if (pw) {
home_path = fs::path{pw->pw_dir};
} else {
if (!pw) {
LOG_ERROR(Common_Filesystem, "Failed to get the home path of the current user");
return {};
}
return home_path;
return fs::path{pw->pw_dir};
}
fs::path GetDataDirectory(const std::string& env_name) {
fs::path data_path;
const char* data_env_var = getenv(env_name.c_str());
if (data_env_var) {
data_path = fs::path{data_env_var};
return data_path;
return fs::path{data_env_var};
}
if (env_name == "XDG_DATA_HOME") {
data_path = GetHomeDirectory() / ".local/share";
return GetHomeDirectory() / ".local/share";
} else if (env_name == "XDG_CACHE_HOME") {
data_path = GetHomeDirectory() / ".cache";
return GetHomeDirectory() / ".cache";
} else if (env_name == "XDG_CONFIG_HOME") {
data_path = GetHomeDirectory() / ".config";
return GetHomeDirectory() / ".config";
}
return data_path;
return {};
}
#endif

View File

@@ -12,28 +12,17 @@
namespace Common::FS {
enum class YuzuPath {
/// Where yuzu stores its data.
YuzuDir,
/// Where cached filesystem data is stored.
CacheDir,
/// Where config files are stored.
ConfigDir,
/// Where dumped data is stored.
DumpDir,
/// Where key files are stored.
KeysDir,
/// Where cheat/mod files are stored.
LoadDir,
/// Where log files are stored.
LogDir,
/// Where the emulated NAND is stored.
NANDDir,
/// Where yuzu screenshots are stored.
ScreenshotsDir,
/// Where the emulated SDMC is stored.
SDMCDir,
/// Where shaders are stored.
ShaderDir,
YuzuDir, // Where yuzu stores its data.
CacheDir, // Where cached filesystem data is stored.
ConfigDir, // Where config files are stored.
DumpDir, // Where dumped data is stored.
KeysDir, // Where key files are stored.
LoadDir, // Where cheat/mod files are stored.
LogDir, // Where log files are stored.
NANDDir, // Where the emulated NAND is stored.
ScreenshotsDir, // Where yuzu screenshots are stored.
SDMCDir, // Where the emulated SDMC is stored.
ShaderDir, // Where shaders are stored.
};
/**
@@ -51,8 +40,6 @@ enum class YuzuPath {
* A given path is valid if it meets these conditions:
* - The path is not empty
* - The path is not too long
* - The path relative to the platform-specific root path does not contain
* any of the following characters: ':', '*', '?', '"', '<', '>', '|'
*
* @param path Filesystem path
*
@@ -64,8 +51,7 @@ enum class YuzuPath {
template <typename Path>
[[nodiscard]] bool ValidatePath(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return ValidatePath(ToU8String(path));
} else {
return ValidatePath(std::filesystem::path{path});
@@ -204,8 +190,7 @@ template <typename Path1, typename Path2>
template <typename Path>
[[nodiscard]] std::filesystem::path RemoveTrailingSeparators(const Path& path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
return RemoveTrailingSeparators(ToU8String(path));
} else {
return RemoveTrailingSeparators(std::filesystem::path{path});
@@ -245,8 +230,7 @@ void SetYuzuPath(YuzuPath yuzu_path, const std::filesystem::path& new_path);
template <typename Path>
[[nodiscard]] void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) {
using ValueType = typename Path::value_type;
if constexpr (IsChar<ValueType>) {
if constexpr (IsChar<typename Path::value_type>) {
SetYuzuPath(yuzu_path, ToU8String(new_path));
} else {
SetYuzuPath(yuzu_path, std::filesystem::path{new_path});