diff options
-rw-r--r-- | Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp | 1 | ||||
-rw-r--r-- | Userland/Applications/Browser/main.cpp | 9 | ||||
-rw-r--r-- | Userland/Applications/Escalator/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/Escalator/main.cpp | 6 | ||||
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.cpp | 14 | ||||
-rw-r--r-- | Userland/Applications/FileManager/PropertiesWindow.cpp | 5 | ||||
-rw-r--r-- | Userland/Applications/FileManager/main.cpp | 9 | ||||
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.cpp | 1 | ||||
-rw-r--r-- | Userland/Applications/Run/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/Run/RunWindow.cpp | 11 | ||||
-rw-r--r-- | Userland/Applications/SpaceAnalyzer/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/Terminal/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/ThemeEditor/main.cpp | 10 |
14 files changed, 36 insertions, 40 deletions
diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp index 2739689ff5..6b0720e4b1 100644 --- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp +++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp @@ -9,7 +9,6 @@ #include "WavefrontOBJLoader.h" #include <AK/FixedArray.h> #include <AK/String.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/File.h> #include <stdlib.h> diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index d485e9bd1a..7b92e10d34 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -14,7 +14,6 @@ #include <Applications/Browser/WindowActions.h> #include <LibConfig/Client.h> #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/FileWatcher.h> #include <LibCore/StandardPaths.h> #include <LibCore/System.h> @@ -131,16 +130,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } - auto url_from_argument_string = [](DeprecatedString const& string) -> URL { + auto url_from_argument_string = [](DeprecatedString const& string) -> ErrorOr<URL> { if (FileSystem::exists(string)) { - return URL::create_with_file_scheme(Core::DeprecatedFile::real_path_for(string)); + return URL::create_with_file_scheme(TRY(FileSystem::real_path(string)).to_deprecated_string()); } return Browser::url_from_user_input(string); }; URL first_url = Browser::url_from_user_input(Browser::g_home_url); if (!specified_urls.is_empty()) - first_url = url_from_argument_string(specified_urls.first()); + first_url = TRY(url_from_argument_string(specified_urls.first())); auto cookie_jar = TRY(Browser::CookieJar::create(*database)); auto window = Browser::BrowserWindow::construct(cookie_jar, first_url); @@ -176,7 +175,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }; for (size_t i = 1; i < specified_urls.size(); ++i) - window->create_new_tab(url_from_argument_string(specified_urls[i]), Web::HTML::ActivateTab::No); + window->create_new_tab(TRY(url_from_argument_string(specified_urls[i])), Web::HTML::ActivateTab::No); window->show(); diff --git a/Userland/Applications/Escalator/CMakeLists.txt b/Userland/Applications/Escalator/CMakeLists.txt index 3078c620e4..ef8f91636a 100644 --- a/Userland/Applications/Escalator/CMakeLists.txt +++ b/Userland/Applications/Escalator/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(Escalator ICON app-escalator) -target_link_libraries(Escalator PRIVATE LibCore LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Escalator PRIVATE LibCore LibFileSystem LibDesktop LibGfx LibGUI LibMain) diff --git a/Userland/Applications/Escalator/main.cpp b/Userland/Applications/Escalator/main.cpp index 7bcce41429..1f1464162b 100644 --- a/Userland/Applications/Escalator/main.cpp +++ b/Userland/Applications/Escalator/main.cpp @@ -9,8 +9,8 @@ #include <AK/DeprecatedString.h> #include <LibCore/Account.h> #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/System.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Application.h> #include <LibGUI/Desktop.h> #include <LibGUI/MessageBox.h> @@ -33,8 +33,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); - auto executable_path = Core::DeprecatedFile::resolve_executable_from_environment(command[0]); - if (!executable_path.has_value()) { + auto executable_path = FileSystem::resolve_executable_from_environment(command[0]); + if (executable_path.is_error()) { GUI::MessageBox::show_error(nullptr, DeprecatedString::formatted("Could not execute command {}: Command not found.", command[0])); return 127; } diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 4d9b182cfb..efb908d993 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -11,7 +11,6 @@ #include <AK/NumberFormat.h> #include <AK/StringBuilder.h> #include <LibConfig/Client.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/MimeData.h> #include <LibCore/StandardPaths.h> #include <LibFileSystem/FileSystem.h> @@ -406,18 +405,21 @@ void DirectoryView::add_path_to_history(DeprecatedString path) bool DirectoryView::open(DeprecatedString const& path) { - auto real_path = Core::DeprecatedFile::real_path_for(path); - if (real_path.is_null() || !FileSystem::is_directory(path)) + auto error_or_real_path = FileSystem::real_path(path); + if (error_or_real_path.is_error() || !FileSystem::is_directory(path)) return false; - if (chdir(real_path.characters()) < 0) { + auto real_path = error_or_real_path.release_value(); + if (Core::System::chdir(real_path).is_error()) { perror("chdir"); + return false; } - if (model().root_path() == real_path) { + + if (model().root_path() == real_path.to_deprecated_string()) { refresh(); } else { set_active_widget(¤t_view()); - model().set_root_path(real_path); + model().set_root_path(real_path.to_deprecated_string()); } return true; } diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 2ce754edfb..5ae384204f 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -10,7 +10,6 @@ #include <AK/NumberFormat.h> #include <Applications/FileManager/DirectoryView.h> #include <Applications/FileManager/PropertiesWindowGeneralTabGML.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/Directory.h> #include <LibCore/System.h> #include <LibDesktop/Launcher.h> @@ -102,11 +101,11 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename) type->set_text(get_description(m_mode)); if (S_ISLNK(m_mode)) { - auto link_destination_or_error = Core::DeprecatedFile::read_link(m_path); + auto link_destination_or_error = FileSystem::read_link(m_path); if (link_destination_or_error.is_error()) { perror("readlink"); } else { - auto link_destination = link_destination_or_error.release_value(); + auto link_destination = link_destination_or_error.release_value().to_deprecated_string(); auto* link_location = general_tab->find_descendant_of_type_named<GUI::LinkLabel>("link_location"); link_location->set_text(link_destination); link_location->on_click = [link_destination] { diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 129880e706..5b1edd1772 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -19,7 +19,6 @@ #include <LibConfig/Client.h> #include <LibConfig/Listener.h> #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/Process.h> #include <LibCore/StandardPaths.h> #include <LibCore/System.h> @@ -109,8 +108,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) LexicalPath path(initial_location); if (!initial_location.is_empty()) { - if (!ignore_path_resolution) - initial_location = Core::DeprecatedFile::real_path_for(initial_location); + if (auto error_or_path = FileSystem::real_path(initial_location); !ignore_path_resolution && !error_or_path.is_error()) + initial_location = error_or_path.release_value().to_deprecated_string(); if (!FileSystem::is_directory(initial_location)) { // We want to extract zips to a temporary directory when FileManager is launched with a .zip file as its first argument @@ -142,8 +141,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } - if (initial_location.is_empty()) - initial_location = Core::DeprecatedFile::current_working_directory(); + if (auto error_or_cwd = FileSystem::current_working_directory(); initial_location.is_empty() && !error_or_cwd.is_error()) + initial_location = error_or_cwd.release_value().to_deprecated_string(); if (initial_location.is_empty()) initial_location = Core::StandardPaths::home_directory(); diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index ee31d37025..c48b1dc66c 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -12,7 +12,6 @@ #include "ViewWidget.h" #include <AK/LexicalPath.h> #include <AK/StringBuilder.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/Directory.h> #include <LibCore/MappedFile.h> #include <LibCore/MimeData.h> diff --git a/Userland/Applications/Run/CMakeLists.txt b/Userland/Applications/Run/CMakeLists.txt index 75b97384f2..777a876f63 100644 --- a/Userland/Applications/Run/CMakeLists.txt +++ b/Userland/Applications/Run/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(Run ICON app-run) -target_link_libraries(Run PRIVATE LibCore LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Run PRIVATE LibCore LibFileSystem LibDesktop LibGfx LibGUI LibMain) diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index f97f90dae2..791c54dfd0 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -9,9 +9,9 @@ #include <AK/LexicalPath.h> #include <AK/URL.h> #include <Applications/Run/RunGML.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/StandardPaths.h> #include <LibDesktop/Launcher.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Button.h> #include <LibGUI/Event.h> #include <LibGUI/FilePicker.h> @@ -142,13 +142,12 @@ bool RunWindow::run_via_launch(DeprecatedString const& run_input) auto url = URL::create_with_url_or_path(run_input); if (url.scheme() == "file") { - auto real_path = Core::DeprecatedFile::real_path_for(url.path()); - if (real_path.is_null()) { - // errno *should* be preserved from Core::DeprecatedFile::real_path_for(). - warnln("Failed to launch '{}': {}", url.path(), strerror(errno)); + auto real_path_or_error = FileSystem::real_path(url.path()); + if (real_path_or_error.is_error()) { + warnln("Failed to launch '{}': {}", url.path(), real_path_or_error.error()); return false; } - url = URL::create_with_url_or_path(real_path); + url = URL::create_with_url_or_path(real_path_or_error.release_value().to_deprecated_string()); } if (!Desktop::Launcher::open(url)) { diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 7fb7eef626..39d551d64c 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -147,7 +147,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (tree_map_widget.viewpoint() == 0) window->set_title("/ - SpaceAnalyzer"); - breadcrumbbar.append_segment("/", GUI::FileIconProvider::icon_for_path("/").bitmap_for_size(16), "/", "/"); + breadcrumbbar.append_segment("/", GUI::FileIconProvider::icon_for_path("/"sv).bitmap_for_size(16), "/", "/"); continue; } diff --git a/Userland/Applications/Terminal/CMakeLists.txt b/Userland/Applications/Terminal/CMakeLists.txt index 85118ec92a..f4622cf2ff 100644 --- a/Userland/Applications/Terminal/CMakeLists.txt +++ b/Userland/Applications/Terminal/CMakeLists.txt @@ -9,4 +9,4 @@ set(SOURCES ) serenity_app(Terminal ICON app-terminal) -target_link_libraries(Terminal PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibVT LibMain) +target_link_libraries(Terminal PRIVATE LibConfig LibCore LibFileSystem LibDesktop LibGfx LibGUI LibVT LibMain) diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 343c13913b..0bb182d6d3 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -10,10 +10,10 @@ #include <LibConfig/Client.h> #include <LibConfig/Listener.h> #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> #include <LibCore/System.h> #include <LibDesktop/Launcher.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 4290744d36..607f25dc12 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -10,8 +10,8 @@ #include "MainWidget.h" #include <LibCore/ArgsParser.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/System.h> +#include <LibFileSystem/FileSystem.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> @@ -33,10 +33,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) parser.add_positional_argument(file_to_edit, "Theme file to edit", "file", Core::ArgsParser::Required::No); parser.parse(arguments); - Optional<DeprecatedString> path = {}; + Optional<String> path = {}; - if (!file_to_edit.is_empty()) - path = Core::DeprecatedFile::absolute_path(file_to_edit); + if (auto error_or_path = FileSystem::absolute_path(file_to_edit); !file_to_edit.is_empty() && !error_or_path.is_error()) + path = error_or_path.release_value(); TRY(Core::System::pledge("stdio recvfd sendfd thread rpath unix")); TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw")); @@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) // Note: This is deferred to ensure that the window has already popped and thus proper window stealing can be performed. app->event_loop().deferred_invoke( [&window, &path, &main_widget]() { - auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path.value()); + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path.value().to_deprecated_string()); if (response.is_error()) GUI::MessageBox::show_error(window, DeprecatedString::formatted("Opening \"{}\" failed: {}", path.value(), response.error())); else { |