mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibCore: Add Core::File::real_path_for()
A slightly convenient wrapper around realpath(3).
This commit is contained in:
parent
fdfda6dec2
commit
d54ace5f04
Notes:
sideshowbarker
2024-07-19 05:41:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d54ace5f044
2 changed files with 12 additions and 0 deletions
|
@ -119,4 +119,15 @@ bool File::exists(const String& filename)
|
|||
return stat(filename.characters(), &st) == 0;
|
||||
}
|
||||
|
||||
String File::real_path_for(const String& filename)
|
||||
{
|
||||
if (filename.is_null())
|
||||
return {};
|
||||
auto* path = realpath(filename.characters(), nullptr);
|
||||
String real_path(path);
|
||||
free(path);
|
||||
return real_path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
static bool is_directory(const String& filename);
|
||||
|
||||
static bool exists(const String& filename);
|
||||
static String real_path_for(const String& filename);
|
||||
|
||||
virtual bool open(IODevice::OpenMode) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue