mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 09:17:36 +00:00
LibFileSystem: Add FileSystem::is_regular_file
This commit is contained in:
parent
a5fd80a336
commit
b2d33c5689
2 changed files with 21 additions and 0 deletions
|
@ -121,6 +121,24 @@ bool is_char_device(int fd)
|
||||||
return S_ISCHR(st.st_mode);
|
return S_ISCHR(st.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_regular_file(StringView path)
|
||||||
|
{
|
||||||
|
auto st_or_error = Core::System::stat(path);
|
||||||
|
if (st_or_error.is_error())
|
||||||
|
return false;
|
||||||
|
auto st = st_or_error.release_value();
|
||||||
|
return S_ISREG(st.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_regular_file(int fd)
|
||||||
|
{
|
||||||
|
auto st_or_error = Core::System::fstat(fd);
|
||||||
|
if (st_or_error.is_error())
|
||||||
|
return false;
|
||||||
|
auto st = st_or_error.release_value();
|
||||||
|
return S_ISREG(st.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
bool is_directory(StringView path)
|
bool is_directory(StringView path)
|
||||||
{
|
{
|
||||||
auto st_or_error = Core::System::stat(path);
|
auto st_or_error = Core::System::stat(path);
|
||||||
|
|
|
@ -25,6 +25,9 @@ ErrorOr<String> real_path(StringView path);
|
||||||
bool exists(StringView path);
|
bool exists(StringView path);
|
||||||
bool exists(int fd);
|
bool exists(int fd);
|
||||||
|
|
||||||
|
bool is_regular_file(StringView path);
|
||||||
|
bool is_regular_file(int fd);
|
||||||
|
|
||||||
bool is_directory(StringView path);
|
bool is_directory(StringView path);
|
||||||
bool is_directory(int fd);
|
bool is_directory(int fd);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue