mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibCore: Implement File::is_link()
It was already possible to check if a path was a directory or a device. Now, it is possible to check if a path is a link in a similar manner.
This commit is contained in:
parent
8823548a4e
commit
3289b6a887
2 changed files with 19 additions and 0 deletions
|
@ -130,6 +130,22 @@ bool File::is_directory(const String& filename)
|
|||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link() const
|
||||
{
|
||||
struct stat stat;
|
||||
if (fstat(fd(), &stat) < 0)
|
||||
return false;
|
||||
return S_ISLNK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link(const String& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (lstat(filename.characters(), &st) < 0)
|
||||
return false;
|
||||
return S_ISLNK(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::exists(const String& filename)
|
||||
{
|
||||
struct stat st;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue