From cfd26f53f00e7222dab5f9ddaabc8ad3adfdc4b0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Mar 2015 17:28:27 +0100 Subject: fs/io/FileOutputStream: fix wrong #ifdef WIN32 --- src/fs/io/FileOutputStream.cxx | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'src/fs/io/FileOutputStream.cxx') diff --git a/src/fs/io/FileOutputStream.cxx b/src/fs/io/FileOutputStream.cxx index 265594c26..a4ef8f6b4 100644 --- a/src/fs/io/FileOutputStream.cxx +++ b/src/fs/io/FileOutputStream.cxx @@ -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 -- cgit v1.2.3