Commit eb0ff32e authored by Max Kellermann's avatar Max Kellermann

system/FileDescriptor: add Open() overload with wchar_t path

parent cf0120e8
...@@ -74,6 +74,17 @@ FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept ...@@ -74,6 +74,17 @@ FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept
return IsDefined(); return IsDefined();
} }
#ifdef _WIN32
bool
FileDescriptor::Open(const wchar_t *pathname, int flags, mode_t mode) noexcept
{
fd = ::_wopen(pathname, flags | O_NOCTTY | O_CLOEXEC, mode);
return IsDefined();
}
#endif
bool bool
FileDescriptor::OpenReadOnly(const char *pathname) noexcept FileDescriptor::OpenReadOnly(const char *pathname) noexcept
{ {
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#include <signal.h> #include <signal.h>
#endif #endif
#ifdef _WIN32
#include <wchar.h>
#endif
/** /**
* An OO wrapper for a UNIX file descriptor. * An OO wrapper for a UNIX file descriptor.
* *
...@@ -97,6 +101,11 @@ public: ...@@ -97,6 +101,11 @@ public:
} }
bool Open(const char *pathname, int flags, mode_t mode=0666) noexcept; bool Open(const char *pathname, int flags, mode_t mode=0666) noexcept;
#ifdef _WIN32
bool Open(const wchar_t *pathname, int flags, mode_t mode=0666) noexcept;
#endif
bool OpenReadOnly(const char *pathname) noexcept; bool OpenReadOnly(const char *pathname) noexcept;
#ifndef WIN32 #ifndef WIN32
......
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