diff options
author | bunnei <bunneidev@gmail.com> | 2021-06-22 17:21:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 17:21:59 -0700 |
commit | 0308a2679ed87aa9cb07e2bde19e165dc454c322 (patch) | |
tree | a1d29aacabab533673bff8043ec11864d68ed022 /src/common/fs/file.h | |
parent | 255f8d22d7cbb85b6d7742d46a1a6c55262ad4e1 (diff) | |
parent | 2fa207058ba6cb1c4d519942e5543bd942f03f6c (diff) |
Merge pull request #6493 from Morph1984/fs-nodiscard
common: fs: Miscellaneous changes
Diffstat (limited to 'src/common/fs/file.h')
-rw-r--r-- | src/common/fs/file.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 0f10b6003..588fe619d 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -49,7 +49,7 @@ void OpenFileStream(FileStream& file_stream, const Path& path, std::ios_base::op /** * Reads an entire file at path and returns a string of the contents read from the file. - * If the filesystem object at path is not a file, this function returns an empty string. + * If the filesystem object at path is not a regular file, this function returns an empty string. * * @param path Filesystem path * @param type File type @@ -72,7 +72,8 @@ template <typename Path> /** * Writes a string to a file at path and returns the number of characters successfully written. * If a file already exists at path, its contents will be erased. - * If the filesystem object at path is not a file, this function returns 0. + * If a file does not exist at path, it creates and opens a new empty file for writing. + * If the filesystem object at path exists and is not a regular file, this function returns 0. * * @param path Filesystem path * @param type File type @@ -95,7 +96,8 @@ template <typename Path> /** * Appends a string to a file at path and returns the number of characters successfully written. - * If the filesystem object at path is not a file, this function returns 0. + * If a file does not exist at path, it creates and opens a new empty file for appending. + * If the filesystem object at path exists and is not a regular file, this function returns 0. * * @param path Filesystem path * @param type File type @@ -394,11 +396,11 @@ public: [[nodiscard]] size_t WriteString(std::span<const char> string) const; /** - * Flushes any unwritten buffered data into the file. + * Attempts to flush any unwritten buffered data into the file and flush the file into the disk. * * @returns True if the flush was successful, false otherwise. */ - [[nodiscard]] bool Flush() const; + bool Flush() const; /** * Resizes the file to a given size. |