diff options
Diffstat (limited to 'src/common/fs/fs.h')
| -rw-r--r-- | src/common/fs/fs.h | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/common/fs/fs.h b/src/common/fs/fs.h index f6f256349..183126de3 100644 --- a/src/common/fs/fs.h +++ b/src/common/fs/fs.h | |||
| @@ -48,18 +48,18 @@ template <typename Path> | |||
| 48 | * | 48 | * |
| 49 | * Failures occur when: | 49 | * Failures occur when: |
| 50 | * - Input path is not valid | 50 | * - Input path is not valid |
| 51 | * - Filesystem object at path is not a file | 51 | * - Filesystem object at path is not a regular file |
| 52 | * - Filesystem at path is read only | 52 | * - Filesystem at path is read only |
| 53 | * | 53 | * |
| 54 | * @param path Filesystem path | 54 | * @param path Filesystem path |
| 55 | * | 55 | * |
| 56 | * @returns True if file removal succeeds or file does not exist, false otherwise. | 56 | * @returns True if file removal succeeds or file does not exist, false otherwise. |
| 57 | */ | 57 | */ |
| 58 | [[nodiscard]] bool RemoveFile(const std::filesystem::path& path); | 58 | bool RemoveFile(const std::filesystem::path& path); |
| 59 | 59 | ||
| 60 | #ifdef _WIN32 | 60 | #ifdef _WIN32 |
| 61 | template <typename Path> | 61 | template <typename Path> |
| 62 | [[nodiscard]] bool RemoveFile(const Path& path) { | 62 | bool RemoveFile(const Path& path) { |
| 63 | if constexpr (IsChar<typename Path::value_type>) { | 63 | if constexpr (IsChar<typename Path::value_type>) { |
| 64 | return RemoveFile(ToU8String(path)); | 64 | return RemoveFile(ToU8String(path)); |
| 65 | } else { | 65 | } else { |
| @@ -74,7 +74,7 @@ template <typename Path> | |||
| 74 | * Failures occur when: | 74 | * Failures occur when: |
| 75 | * - One or both input path(s) is not valid | 75 | * - One or both input path(s) is not valid |
| 76 | * - Filesystem object at old_path does not exist | 76 | * - Filesystem object at old_path does not exist |
| 77 | * - Filesystem object at old_path is not a file | 77 | * - Filesystem object at old_path is not a regular file |
| 78 | * - Filesystem object at new_path exists | 78 | * - Filesystem object at new_path exists |
| 79 | * - Filesystem at either path is read only | 79 | * - Filesystem at either path is read only |
| 80 | * | 80 | * |
| @@ -110,8 +110,8 @@ template <typename Path1, typename Path2> | |||
| 110 | * | 110 | * |
| 111 | * Failures occur when: | 111 | * Failures occur when: |
| 112 | * - Input path is not valid | 112 | * - Input path is not valid |
| 113 | * - Filesystem object at path is not a file | 113 | * - Filesystem object at path exists and is not a regular file |
| 114 | * - The file is not opened | 114 | * - The file is not open |
| 115 | * | 115 | * |
| 116 | * @param path Filesystem path | 116 | * @param path Filesystem path |
| 117 | * @param mode File access mode | 117 | * @param mode File access mode |
| @@ -251,11 +251,11 @@ template <typename Path> | |||
| 251 | * | 251 | * |
| 252 | * @returns True if directory removal succeeds or directory does not exist, false otherwise. | 252 | * @returns True if directory removal succeeds or directory does not exist, false otherwise. |
| 253 | */ | 253 | */ |
| 254 | [[nodiscard]] bool RemoveDir(const std::filesystem::path& path); | 254 | bool RemoveDir(const std::filesystem::path& path); |
| 255 | 255 | ||
| 256 | #ifdef _WIN32 | 256 | #ifdef _WIN32 |
| 257 | template <typename Path> | 257 | template <typename Path> |
| 258 | [[nodiscard]] bool RemoveDir(const Path& path) { | 258 | bool RemoveDir(const Path& path) { |
| 259 | if constexpr (IsChar<typename Path::value_type>) { | 259 | if constexpr (IsChar<typename Path::value_type>) { |
| 260 | return RemoveDir(ToU8String(path)); | 260 | return RemoveDir(ToU8String(path)); |
| 261 | } else { | 261 | } else { |
| @@ -276,11 +276,11 @@ template <typename Path> | |||
| 276 | * | 276 | * |
| 277 | * @returns True if the directory and all of its contents are removed successfully, false otherwise. | 277 | * @returns True if the directory and all of its contents are removed successfully, false otherwise. |
| 278 | */ | 278 | */ |
| 279 | [[nodiscard]] bool RemoveDirRecursively(const std::filesystem::path& path); | 279 | bool RemoveDirRecursively(const std::filesystem::path& path); |
| 280 | 280 | ||
| 281 | #ifdef _WIN32 | 281 | #ifdef _WIN32 |
| 282 | template <typename Path> | 282 | template <typename Path> |
| 283 | [[nodiscard]] bool RemoveDirRecursively(const Path& path) { | 283 | bool RemoveDirRecursively(const Path& path) { |
| 284 | if constexpr (IsChar<typename Path::value_type>) { | 284 | if constexpr (IsChar<typename Path::value_type>) { |
| 285 | return RemoveDirRecursively(ToU8String(path)); | 285 | return RemoveDirRecursively(ToU8String(path)); |
| 286 | } else { | 286 | } else { |
| @@ -301,11 +301,11 @@ template <typename Path> | |||
| 301 | * | 301 | * |
| 302 | * @returns True if all of the directory's contents are removed successfully, false otherwise. | 302 | * @returns True if all of the directory's contents are removed successfully, false otherwise. |
| 303 | */ | 303 | */ |
| 304 | [[nodiscard]] bool RemoveDirContentsRecursively(const std::filesystem::path& path); | 304 | bool RemoveDirContentsRecursively(const std::filesystem::path& path); |
| 305 | 305 | ||
| 306 | #ifdef _WIN32 | 306 | #ifdef _WIN32 |
| 307 | template <typename Path> | 307 | template <typename Path> |
| 308 | [[nodiscard]] bool RemoveDirContentsRecursively(const Path& path) { | 308 | bool RemoveDirContentsRecursively(const Path& path) { |
| 309 | if constexpr (IsChar<typename Path::value_type>) { | 309 | if constexpr (IsChar<typename Path::value_type>) { |
| 310 | return RemoveDirContentsRecursively(ToU8String(path)); | 310 | return RemoveDirContentsRecursively(ToU8String(path)); |
| 311 | } else { | 311 | } else { |
| @@ -435,11 +435,13 @@ template <typename Path> | |||
| 435 | #endif | 435 | #endif |
| 436 | 436 | ||
| 437 | /** | 437 | /** |
| 438 | * Returns whether a filesystem object at path is a file. | 438 | * Returns whether a filesystem object at path is a regular file. |
| 439 | * A regular file is a file that stores text or binary data. | ||
| 440 | * It is not a directory, symlink, FIFO, socket, block device, or character device. | ||
| 439 | * | 441 | * |
| 440 | * @param path Filesystem path | 442 | * @param path Filesystem path |
| 441 | * | 443 | * |
| 442 | * @returns True if a filesystem object at path is a file, false otherwise. | 444 | * @returns True if a filesystem object at path is a regular file, false otherwise. |
| 443 | */ | 445 | */ |
| 444 | [[nodiscard]] bool IsFile(const std::filesystem::path& path); | 446 | [[nodiscard]] bool IsFile(const std::filesystem::path& path); |
| 445 | 447 | ||