system/FileDescriptor: add method IsValid()
This commit is contained in:
@@ -57,6 +57,16 @@
|
|||||||
#define O_CLOEXEC 0
|
#define O_CLOEXEC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
|
||||||
|
bool
|
||||||
|
FileDescriptor::IsValid() const noexcept
|
||||||
|
{
|
||||||
|
return IsDefined() && fcntl(fd, F_GETFL) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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
|
||||||
{
|
{
|
||||||
|
@@ -64,6 +64,14 @@ public:
|
|||||||
return fd >= 0;
|
return fd >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
/**
|
||||||
|
* Ask the kernel whether this is a valid file descriptor.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool IsValid() const noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file descriptor. This may only be called if
|
* Returns the file descriptor. This may only be called if
|
||||||
* IsDefined() returns true.
|
* IsDefined() returns true.
|
||||||
|
Reference in New Issue
Block a user