From b2fbb95c42b0a5fe1423ed56f7c41dd74d111b66 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 14 Jan 2005 14:05:25 +0000 Subject: [PATCH] src/file_win.cpp --- src/file_win.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/file_win.cpp b/src/file_win.cpp index 2e1fac55b..223247c7e 100644 --- a/src/file_win.cpp +++ b/src/file_win.cpp @@ -62,9 +62,15 @@ namespace int err = GetLastError(); #ifdef _UNICODE - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPWSTR)(LPCSTR)&buffer, 0, 0); + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM + |FORMAT_MESSAGE_ALLOCATE_BUFFER + , 0, err, 0, (LPWSTR)(LPCSTR)&buffer, 0, 0); #else - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPSTR)&buffer, 0, 0); + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM + |FORMAT_MESSAGE_ALLOCATE_BUFFER + , 0, err, 0, (LPSTR)&buffer, 0, 0); #endif auto_LocalFree auto_free(buffer); // needed for exception safety @@ -117,7 +123,7 @@ namespace libtorrent , access_mask , FILE_SHARE_READ , 0 - , (flags & read_flag)?OPEN_EXISTING:OPEN_ALWAYS + , (flags & write_flag)?OPEN_ALWAYS:OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , 0); #else @@ -126,7 +132,7 @@ namespace libtorrent , access_mask , FILE_SHARE_READ , 0 - , (flags & read_flag)?OPEN_EXISTING:OPEN_ALWAYS + , (flags & write_flag)?OPEN_ALWAYS:OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , 0); #endif @@ -134,8 +140,7 @@ namespace libtorrent if (new_handle == INVALID_HANDLE_VALUE) { std::stringstream s; - s << "couldn't open file '" << file_name << "'"; - throw file_error(s.str()); + throw_exception(file_name); } // will only close old file if the open succeeded close();