Commit 6387b528 authored by Max Kellermann's avatar Max Kellermann

fs/io/FileOutputStream: seek end-of-file in AppendFileOutputStream ctor

parent 077e95da
...@@ -226,6 +226,12 @@ AppendFileOutputStream::AppendFileOutputStream(Path _path, Error &error) ...@@ -226,6 +226,12 @@ AppendFileOutputStream::AppendFileOutputStream(Path _path, Error &error)
if (!IsDefined()) if (!IsDefined())
error.FormatLastError("Failed to append to %s", error.FormatLastError("Failed to append to %s",
GetPath().ToUTF8().c_str()); GetPath().ToUTF8().c_str());
if (!SeekEOF()) {
error.FormatLastError("Failed seek end-of-file of %s",
GetPath().ToUTF8().c_str());
Close();
}
#else #else
if (!SetFD().Open(GetPath().c_str(), if (!SetFD().Open(GetPath().c_str(),
O_WRONLY|O_APPEND)) O_WRONLY|O_APPEND))
......
...@@ -95,6 +95,12 @@ protected: ...@@ -95,6 +95,12 @@ protected:
#endif #endif
} }
#ifdef WIN32
bool SeekEOF() {
return SetFilePointer(handle, 0, nullptr, FILE_END);
}
#endif
public: public:
bool IsDefined() const { bool IsDefined() const {
#ifdef WIN32 #ifdef WIN32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment