fs/io/FileOutputStream: seek end-of-file in AppendFileOutputStream ctor
This commit is contained in:
parent
077e95da85
commit
6387b52896
@ -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))
|
||||
|
@ -95,6 +95,12 @@ protected:
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
bool SeekEOF() {
|
||||
return SetFilePointer(handle, 0, nullptr, FILE_END);
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool IsDefined() const {
|
||||
#ifdef WIN32
|
||||
|
Loading…
Reference in New Issue
Block a user