Commit d036e208 authored by Max Kellermann's avatar Max Kellermann

system/FileDescriptor: add openat() wrapper

parent 9151b84c
...@@ -76,6 +76,18 @@ FileDescriptor::IsSocket() const noexcept ...@@ -76,6 +76,18 @@ FileDescriptor::IsSocket() const noexcept
#endif #endif
#ifdef __linux
bool
FileDescriptor::Open(FileDescriptor dir, const char *pathname,
int flags, mode_t mode) noexcept
{
fd = ::openat(dir.Get(), pathname, flags | O_NOCTTY | O_CLOEXEC, mode);
return IsDefined();
}
#endif
bool bool
FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept
{ {
......
...@@ -116,6 +116,11 @@ public: ...@@ -116,6 +116,11 @@ public:
return FileDescriptor(-1); return FileDescriptor(-1);
} }
#ifdef __linux
bool Open(FileDescriptor dir, const char *pathname,
int flags, mode_t mode=0666) noexcept;
#endif
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 #ifdef _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