summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2022-03-23 16:36:03 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-24 11:57:51 +0100
commit4a57be824cc6d4fed95f182431ba807b2327395e (patch)
tree6f0185eb39bbf6cd199d30decd63bdbae655c3bb /Userland/Libraries/LibGUI
parent10093a67732431924fc76145443ffac157b50e01 (diff)
downloadserenity-4a57be824cc6d4fed95f182431ba807b2327395e.zip
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.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/FileIconProvider.cpp6
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.cpp6
2 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp
index 27c4b4fa03..821af95491 100644
--- a/Userland/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp
@@ -232,7 +232,11 @@ Icon FileIconProvider::icon_for_path(const String& path, mode_t mode)
return s_directory_icon;
}
if (S_ISLNK(mode)) {
- auto raw_symlink_target = Core::File::read_link(path);
+ auto raw_symlink_target_or_error = Core::File::read_link(path);
+ if (raw_symlink_target_or_error.is_error())
+ return s_symlink_icon;
+
+ auto raw_symlink_target = raw_symlink_target_or_error.release_value();
if (raw_symlink_target.is_null())
return s_symlink_icon;
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp
index 1bf7fbcc04..f4f9cfe364 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp
@@ -61,7 +61,11 @@ bool FileSystemModel::Node::fetch_data(String const& full_path, bool is_root)
mtime = st.st_mtime;
if (S_ISLNK(mode)) {
- symlink_target = Core::File::read_link(full_path);
+ auto sym_link_target_or_error = Core::File::read_link(full_path);
+ if (sym_link_target_or_error.is_error())
+ perror("readlink");
+
+ symlink_target = sym_link_target_or_error.release_value();
if (symlink_target.is_null())
perror("readlink");
}