Commit cfd26f53 authored by Max Kellermann's avatar Max Kellermann

fs/io/FileOutputStream: fix wrong #ifdef WIN32

parent 69ad5671
......@@ -214,32 +214,16 @@ FileOutputStream::Cancel()
RemoveFile(GetPath());
}
#ifdef WIN32
FileOutputStream::FileOutputStream(Path _path, Error &error)
:path(_path),
handle(CreateFile(path.c_str(), GENERIC_WRITE, 0, nullptr,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH,
nullptr))
{
if (handle == INVALID_HANDLE_VALUE) {
const auto path_utf8 = path.ToUTF8();
error.FormatLastError("Failed to create %s",
path_utf8.c_str());
}
}
#else
#endif
AppendFileOutputStream::AppendFileOutputStream(Path _path, Error &error)
:BaseFileOutputStream(_path)
{
#ifdef WIN32
SetHandle(CreateFile(path.c_str(), GENERIC_WRITE, 0, nullptr,
SetHandle(CreateFile(GetPath().c_str(), GENERIC_WRITE, 0, nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH,
nullptr))
nullptr));
if (!IsDefined())
error.FormatLastError("Failed to append to %s",
GetPath().ToUTF8().c_str());
......@@ -257,8 +241,6 @@ AppendFileOutputStream::AppendFileOutputStream(Path _path, Error &error)
#endif
}
#endif
bool
AppendFileOutputStream::Commit(gcc_unused Error &error)
{
......@@ -274,5 +256,3 @@ AppendFileOutputStream::Commit(gcc_unused Error &error)
return success;
#endif
}
#endif
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