From fb644d08acabb3766444342d098b825d2aade552 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Mon, 15 Jan 2024 16:01:39 +0000 Subject: [PATCH] LibFileSystem+Everywhere: Return ByteString current_working_directory() That is, return it *from* current_working_directory(), but I didn't have room. :^) --- Meta/Lagom/Tools/ConfigureComponents/main.cpp | 2 +- Userland/Applications/FileManager/main.cpp | 2 +- Userland/Libraries/LibFileSystem/FileSystem.cpp | 5 ++--- Userland/Libraries/LibFileSystem/FileSystem.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp index b280484a99..879d62ba5f 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp +++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp @@ -234,7 +234,7 @@ int main() auto current_working_directory = FileSystem::current_working_directory(); if (current_working_directory.is_error()) return 1; - auto lexical_cwd = LexicalPath(current_working_directory.release_value().to_byte_string()); + auto lexical_cwd = LexicalPath(current_working_directory.release_value()); auto& parts = lexical_cwd.parts_view(); if (parts.size() < 2 || parts[parts.size() - 2] != "Build") { warnln("\e[31mError:\e[0m This program needs to be executed from inside 'Build/*'."); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index d785737b95..8863954863 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -142,7 +142,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } 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_byte_string(); + initial_location = error_or_cwd.release_value(); if (initial_location.is_empty()) initial_location = Core::StandardPaths::home_directory(); diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index cbae433f04..e1a930ac29 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -23,10 +23,9 @@ namespace FileSystem { -ErrorOr current_working_directory() +ErrorOr current_working_directory() { - auto cwd = TRY(Core::System::getcwd()); - return TRY(String::from_byte_string({ cwd })); + return Core::System::getcwd(); } ErrorOr absolute_path(StringView path) diff --git a/Userland/Libraries/LibFileSystem/FileSystem.h b/Userland/Libraries/LibFileSystem/FileSystem.h index fd633c0f14..6f2171016f 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.h +++ b/Userland/Libraries/LibFileSystem/FileSystem.h @@ -18,7 +18,7 @@ namespace FileSystem { #define DEFAULT_PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin" #define DEFAULT_PATH_SV "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv -ErrorOr current_working_directory(); +ErrorOr current_working_directory(); ErrorOr absolute_path(StringView path); ErrorOr real_path(StringView path);