mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibFileSystem+Everywhere: Return ByteString current_working_directory()
That is, return it *from* current_working_directory(), but I didn't have room. :^)
This commit is contained in:
parent
a7fbb7fd0b
commit
fb644d08ac
Notes:
sideshowbarker
2024-07-17 07:14:09 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/fb644d08ac Pull-request: https://github.com/SerenityOS/serenity/pull/22775 Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 5 additions and 6 deletions
|
@ -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/*'.");
|
||||
|
|
|
@ -142,7 +142,7 @@ ErrorOr<int> 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();
|
||||
|
|
|
@ -23,10 +23,9 @@
|
|||
|
||||
namespace FileSystem {
|
||||
|
||||
ErrorOr<String> current_working_directory()
|
||||
ErrorOr<ByteString> current_working_directory()
|
||||
{
|
||||
auto cwd = TRY(Core::System::getcwd());
|
||||
return TRY(String::from_byte_string({ cwd }));
|
||||
return Core::System::getcwd();
|
||||
}
|
||||
|
||||
ErrorOr<String> absolute_path(StringView path)
|
||||
|
|
|
@ -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<String> current_working_directory();
|
||||
ErrorOr<ByteString> current_working_directory();
|
||||
ErrorOr<String> absolute_path(StringView path);
|
||||
ErrorOr<String> real_path(StringView path);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue