Commit 4c243478 authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

system/FileDescriptor: add method IsRegularFile()

parent ca9daf5e
......@@ -60,6 +60,13 @@ FileDescriptor::IsValid() const noexcept
}
bool
FileDescriptor::IsRegularFile() const noexcept
{
struct stat st;
return IsDefined() && fstat(fd, &st) == 0 && S_ISREG(st.st_mode);
}
bool
FileDescriptor::IsPipe() const noexcept
{
struct stat st;
......
......@@ -79,6 +79,12 @@ public:
bool IsValid() const noexcept;
/**
* Ask the kernel whether this is a regular file.
*/
gcc_pure
bool IsRegularFile() const noexcept;
/**
* Ask the kernel whether this is a pipe.
*/
gcc_pure
......
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