| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <filesystem> |
| | #include <vector> |
| |
|
| | #include "common/fs/fs_util.h" |
| |
|
| | namespace Common::FS { |
| |
|
| | enum class YuzuPath { |
| | YuzuDir, |
| | AmiiboDir, |
| | CacheDir, |
| | ConfigDir, |
| | CrashDumpsDir, |
| | DumpDir, |
| | KeysDir, |
| | LoadDir, |
| | LogDir, |
| | NANDDir, |
| | PlayTimeDir, |
| | ScreenshotsDir, |
| | SDMCDir, |
| | ShaderDir, |
| | TASDir, |
| | IconsDir, |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] bool ValidatePath(const std::filesystem::path& path); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path> |
| | [[nodiscard]] bool ValidatePath(const Path& path) { |
| | if constexpr (IsChar<typename Path::value_type>) { |
| | return ValidatePath(ToU8String(path)); |
| | } else { |
| | return ValidatePath(std::filesystem::path{path}); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path ConcatPath(const std::filesystem::path& first, |
| | const std::filesystem::path& second); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path1, typename Path2> |
| | [[nodiscard]] std::filesystem::path ConcatPath(const Path1& first, const Path2& second) { |
| | using ValueType1 = typename Path1::value_type; |
| | using ValueType2 = typename Path2::value_type; |
| | if constexpr (IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return ConcatPath(ToU8String(first), ToU8String(second)); |
| | } else if constexpr (IsChar<ValueType1> && !IsChar<ValueType2>) { |
| | return ConcatPath(ToU8String(first), second); |
| | } else if constexpr (!IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return ConcatPath(first, ToU8String(second)); |
| | } else { |
| | return ConcatPath(std::filesystem::path{first}, std::filesystem::path{second}); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path ConcatPathSafe(const std::filesystem::path& base, |
| | const std::filesystem::path& offset); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path1, typename Path2> |
| | [[nodiscard]] std::filesystem::path ConcatPathSafe(const Path1& base, const Path2& offset) { |
| | using ValueType1 = typename Path1::value_type; |
| | using ValueType2 = typename Path2::value_type; |
| | if constexpr (IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return ConcatPathSafe(ToU8String(base), ToU8String(offset)); |
| | } else if constexpr (IsChar<ValueType1> && !IsChar<ValueType2>) { |
| | return ConcatPathSafe(ToU8String(base), offset); |
| | } else if constexpr (!IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return ConcatPathSafe(base, ToU8String(offset)); |
| | } else { |
| | return ConcatPathSafe(std::filesystem::path{base}, std::filesystem::path{offset}); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] bool IsPathSandboxed(const std::filesystem::path& base, |
| | const std::filesystem::path& path); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path1, typename Path2> |
| | [[nodiscard]] bool IsPathSandboxed(const Path1& base, const Path2& path) { |
| | using ValueType1 = typename Path1::value_type; |
| | using ValueType2 = typename Path2::value_type; |
| | if constexpr (IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return IsPathSandboxed(ToU8String(base), ToU8String(path)); |
| | } else if constexpr (IsChar<ValueType1> && !IsChar<ValueType2>) { |
| | return IsPathSandboxed(ToU8String(base), path); |
| | } else if constexpr (!IsChar<ValueType1> && IsChar<ValueType2>) { |
| | return IsPathSandboxed(base, ToU8String(path)); |
| | } else { |
| | return IsPathSandboxed(std::filesystem::path{base}, std::filesystem::path{path}); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] bool IsDirSeparator(char character); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] bool IsDirSeparator(char8_t character); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path RemoveTrailingSeparators(const std::filesystem::path& path); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path> |
| | [[nodiscard]] std::filesystem::path RemoveTrailingSeparators(const Path& path) { |
| | if constexpr (IsChar<typename Path::value_type>) { |
| | return RemoveTrailingSeparators(ToU8String(path)); |
| | } else { |
| | return RemoveTrailingSeparators(std::filesystem::path{path}); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void SetAppDirectory(const std::string& app_directory); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] const std::filesystem::path& GetYuzuPath(YuzuPath yuzu_path); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::string GetYuzuPathString(YuzuPath yuzu_path); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | void SetYuzuPath(YuzuPath yuzu_path, const std::filesystem::path& new_path); |
| |
|
| | #ifdef _WIN32 |
| | template <typename Path> |
| | void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) { |
| | if constexpr (IsChar<typename Path::value_type>) { |
| | SetYuzuPath(yuzu_path, ToU8String(new_path)); |
| | } else { |
| | SetYuzuPath(yuzu_path, std::filesystem::path{new_path}); |
| | } |
| | } |
| | #endif |
| |
|
| | #ifdef _WIN32 |
| |
|
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path GetExeDirectory(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path GetAppDataRoamingDirectory(); |
| |
|
| | #else |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path GetHomeDirectory(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] std::filesystem::path GetDataDirectory(const std::string& env_name); |
| |
|
| | #endif |
| |
|
| | #ifdef __APPLE__ |
| |
|
| | [[nodiscard]] std::filesystem::path GetBundleDirectory(); |
| |
|
| | #endif |
| |
|
| | |
| |
|
| | |
| | [[nodiscard]] std::string_view RemoveTrailingSlash(std::string_view path); |
| |
|
| | enum class DirectorySeparator { |
| | ForwardSlash, |
| | BackwardSlash, |
| | PlatformDefault, |
| | }; |
| |
|
| | |
| | |
| | [[nodiscard]] std::vector<std::string_view> SplitPathComponents(std::string_view filename); |
| |
|
| | |
| | |
| | [[nodiscard]] std::vector<std::string> SplitPathComponentsCopy(std::string_view filename); |
| |
|
| | |
| | |
| | [[nodiscard]] std::string SanitizePath( |
| | std::string_view path, |
| | DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash); |
| |
|
| | |
| | [[nodiscard]] std::string GetParentPath(std::string_view path); |
| |
|
| | |
| | [[nodiscard]] std::string_view GetPathWithoutTop(std::string_view path); |
| |
|
| | |
| | [[nodiscard]] std::string_view GetFilename(std::string_view path); |
| |
|
| | |
| | [[nodiscard]] std::string_view GetExtensionFromFilename(std::string_view name); |
| |
|
| | } |
| |
|