diff options
Diffstat (limited to '')
-rw-r--r-- | src/fs/io/FileOutputStream.cxx | 6 | ||||
-rw-r--r-- | src/fs/io/FileOutputStream.hxx | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/fs/io/FileOutputStream.cxx b/src/fs/io/FileOutputStream.cxx index 82d9c3dc1..c7410f180 100644 --- a/src/fs/io/FileOutputStream.cxx +++ b/src/fs/io/FileOutputStream.cxx @@ -226,6 +226,12 @@ AppendFileOutputStream::AppendFileOutputStream(Path _path, Error &error) if (!IsDefined()) error.FormatLastError("Failed to append to %s", GetPath().ToUTF8().c_str()); + + if (!SeekEOF()) { + error.FormatLastError("Failed seek end-of-file of %s", + GetPath().ToUTF8().c_str()); + Close(); + } #else if (!SetFD().Open(GetPath().c_str(), O_WRONLY|O_APPEND)) diff --git a/src/fs/io/FileOutputStream.hxx b/src/fs/io/FileOutputStream.hxx index 9decb6f00..6756de99e 100644 --- a/src/fs/io/FileOutputStream.hxx +++ b/src/fs/io/FileOutputStream.hxx @@ -95,6 +95,12 @@ protected: #endif } +#ifdef WIN32 + bool SeekEOF() { + return SetFilePointer(handle, 0, nullptr, FILE_END); + } +#endif + public: bool IsDefined() const { #ifdef WIN32 |