fs/io/FileOutputStream: fix wrong #ifdef WIN32

This commit is contained in:
Max Kellermann 2015-03-25 17:28:27 +01:00
parent 69ad5671ed
commit cfd26f53f0

View File

@ -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