mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to ErrorOr<String>. The rest of the change is to support the potential of an Error being returned and subsequent release of the value when no Error is returned. Unfortunately at this stage none of the places affected can utililize our TRY() macro.
This commit is contained in:
parent
10093a6773
commit
4a57be824c
12 changed files with 72 additions and 30 deletions
|
@ -271,7 +271,11 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
|
|||
return;
|
||||
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
auto link_target = LexicalPath { Core::File::read_link(path) };
|
||||
auto link_target_or_error = Core::File::read_link(path);
|
||||
if (link_target_or_error.is_error())
|
||||
perror("read_link");
|
||||
|
||||
auto link_target = LexicalPath { link_target_or_error.release_value() };
|
||||
LexicalPath absolute_link_target = link_target.is_absolute() ? link_target : LexicalPath::join(LexicalPath::dirname(path), link_target.string());
|
||||
auto real_path = Core::File::real_path_for(absolute_link_target.string());
|
||||
return for_each_handler_for_path(real_path, [&](const auto& handler) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue