1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibCore: Add File::read_link() :^)

This is a convenient wrapper around readlink() that hides away the details
of buffers and buffer sizes, and simply returns a String. The best part is it
doesn't rely on PATH_MAX :D

It comes in two versions, for Serenity, where we can pass non-null-terminated
strings to syscalls, and where sys$readlink() returns the total link size, and
for other systems, where we have to copy out the string, and always have to do
two syscalls.
This commit is contained in:
Sergey Bugaev 2020-06-16 21:56:00 +03:00 committed by Andreas Kling
parent 47d83800e1
commit d89843f96f
2 changed files with 74 additions and 0 deletions

View file

@ -47,6 +47,7 @@ public:
static bool exists(const String& filename);
static String real_path_for(const String& filename);
static String read_link(const StringView& link_path);
virtual bool open(IODevice::OpenMode) override;