mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
LibCore: Add fd overload of File::is_directory
and File::is_device
This commit is contained in:
parent
9ae97c8cb1
commit
cfb0e1bdb2
2 changed files with 20 additions and 8 deletions
|
@ -104,10 +104,7 @@ int File::leak_fd()
|
|||
|
||||
bool File::is_device() const
|
||||
{
|
||||
struct stat stat;
|
||||
if (fstat(fd(), &stat) < 0)
|
||||
return false;
|
||||
return S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
||||
return is_device(fd());
|
||||
}
|
||||
|
||||
bool File::is_device(DeprecatedString const& filename)
|
||||
|
@ -118,6 +115,14 @@ bool File::is_device(DeprecatedString const& filename)
|
|||
return S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_device(int fd)
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0)
|
||||
return false;
|
||||
return S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_block_device() const
|
||||
{
|
||||
struct stat stat;
|
||||
|
@ -152,10 +157,7 @@ bool File::is_char_device(DeprecatedString const& filename)
|
|||
|
||||
bool File::is_directory() const
|
||||
{
|
||||
struct stat stat;
|
||||
if (fstat(fd(), &stat) < 0)
|
||||
return false;
|
||||
return S_ISDIR(stat.st_mode);
|
||||
return is_directory(fd());
|
||||
}
|
||||
|
||||
bool File::is_directory(DeprecatedString const& filename)
|
||||
|
@ -166,6 +168,14 @@ bool File::is_directory(DeprecatedString const& filename)
|
|||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_directory(int fd)
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0)
|
||||
return false;
|
||||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link() const
|
||||
{
|
||||
struct stat stat;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue