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

This commit is contained in:
Max Kellermann 2017-08-10 19:34:44 +02:00
parent cf0120e8e0
commit eb0ff32efb
2 changed files with 20 additions and 0 deletions

View File

@ -74,6 +74,17 @@ FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept
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
FileDescriptor::OpenReadOnly(const char *pathname) noexcept
{

View File

@ -43,6 +43,10 @@
#include <signal.h>
#endif
#ifdef _WIN32
#include <wchar.h>
#endif
/**
* An OO wrapper for a UNIX file descriptor.
*
@ -97,6 +101,11 @@ public:
}
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;
#ifndef WIN32