mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
tar: Remove unnecessary conversions to String
We use these canonicalized_path variables as StringViews, so it doesn't matter if they are a String or ByteString. And they're paths so shouldn't be String anyway.
This commit is contained in:
parent
1750af83b0
commit
f4b345258d
1 changed files with 3 additions and 3 deletions
|
@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto file = file_or_error.release_value();
|
auto file = file_or_error.release_value();
|
||||||
|
|
||||||
auto statbuf = TRY(Core::System::lstat(path));
|
auto statbuf = TRY(Core::System::lstat(path));
|
||||||
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
|
auto canonicalized_path = LexicalPath::canonicalized_path(path);
|
||||||
// FIXME: We should stream instead of reading the entire file in one go, but TarOutputStream does not have any interface to do so.
|
// FIXME: We should stream instead of reading the entire file in one go, but TarOutputStream does not have any interface to do so.
|
||||||
auto file_content = TRY(file->read_until_eof());
|
auto file_content = TRY(file->read_until_eof());
|
||||||
TRY(tar_stream.add_file(canonicalized_path, statbuf.st_mode, file_content));
|
TRY(tar_stream.add_file(canonicalized_path, statbuf.st_mode, file_content));
|
||||||
|
@ -264,7 +264,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto add_link = [&](ByteString path) -> ErrorOr<void> {
|
auto add_link = [&](ByteString path) -> ErrorOr<void> {
|
||||||
auto statbuf = TRY(Core::System::lstat(path));
|
auto statbuf = TRY(Core::System::lstat(path));
|
||||||
|
|
||||||
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
|
auto canonicalized_path = LexicalPath::canonicalized_path(path);
|
||||||
TRY(tar_stream.add_link(canonicalized_path, statbuf.st_mode, TRY(Core::System::readlink(path))));
|
TRY(tar_stream.add_link(canonicalized_path, statbuf.st_mode, TRY(Core::System::readlink(path))));
|
||||||
if (verbose)
|
if (verbose)
|
||||||
outln("{}", canonicalized_path);
|
outln("{}", canonicalized_path);
|
||||||
|
@ -275,7 +275,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto add_directory = [&](ByteString path, auto handle_directory) -> ErrorOr<void> {
|
auto add_directory = [&](ByteString path, auto handle_directory) -> ErrorOr<void> {
|
||||||
auto statbuf = TRY(Core::System::lstat(path));
|
auto statbuf = TRY(Core::System::lstat(path));
|
||||||
|
|
||||||
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
|
auto canonicalized_path = LexicalPath::canonicalized_path(path);
|
||||||
TRY(tar_stream.add_directory(canonicalized_path, statbuf.st_mode));
|
TRY(tar_stream.add_directory(canonicalized_path, statbuf.st_mode));
|
||||||
if (verbose)
|
if (verbose)
|
||||||
outln("{}", canonicalized_path);
|
outln("{}", canonicalized_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue