diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-07 14:07:28 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-09 14:18:20 +0300 |
commit | dcccba655fe848564e961b3f285ce3a82d3ac73a (patch) | |
tree | 598ced3b406d80c23798672930e1a17cfe112b75 /libbutl/win32-utility.cxx | |
parent | 63b2988e4f2630cc688ff43b7e5f0d4f977896cd (diff) |
Add more support for symlinks on Windows
See mksymlink() for details of the symlinks support on Windows.
Diffstat (limited to 'libbutl/win32-utility.cxx')
-rw-r--r-- | libbutl/win32-utility.cxx | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libbutl/win32-utility.cxx b/libbutl/win32-utility.cxx index b4dda6a..3b44d60 100644 --- a/libbutl/win32-utility.cxx +++ b/libbutl/win32-utility.cxx @@ -9,9 +9,14 @@ #ifdef _WIN32 #ifndef __cpp_lib_modules_ts +#include <string> #include <memory> // unique_ptr + +#include <libbutl/utility.mxx> // throw_system_error() #else import std.core; + +import butl.utility; #endif using namespace std; @@ -20,6 +25,25 @@ namespace butl { namespace win32 { + const nullhandle_t nullhandle (INVALID_HANDLE_VALUE); + + void auto_handle:: + close () + { + if (handle_ != INVALID_HANDLE_VALUE) + { + bool r (CloseHandle (handle_)); + + // If CloseHandle() failed then no reason to expect it to succeed the + // next time. + // + handle_ = INVALID_HANDLE_VALUE; + + if (!r) + throw_system_error (GetLastError ()); + } + } + struct msg_deleter { void operator() (char* p) const {LocalFree (p);} @@ -40,7 +64,7 @@ namespace butl (char*)&msg, 0, 0)) - return "unknown error code " + to_string (code); + return "unknown error code " + std::to_string (code); unique_ptr<char, msg_deleter> m (msg); return msg; |