system/FileDescriptor: add method IsRegularFile()
This commit is contained in:
parent
ca9daf5e19
commit
4c2434788f
@ -59,6 +59,13 @@ FileDescriptor::IsValid() const noexcept
|
||||
return IsDefined() && fcntl(fd, F_GETFL) >= 0;
|
||||
}
|
||||
|
||||
bool
|
||||
FileDescriptor::IsRegularFile() const noexcept
|
||||
{
|
||||
struct stat st;
|
||||
return IsDefined() && fstat(fd, &st) == 0 && S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
bool
|
||||
FileDescriptor::IsPipe() const noexcept
|
||||
{
|
||||
|
@ -78,6 +78,12 @@ public:
|
||||
gcc_pure
|
||||
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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user