Skip to content

Commit

Permalink
Utilities/tar: Open archive file before changing directory
Browse files Browse the repository at this point in the history
Otherwise the utility will fail to open the archive file because it's
presumably not in the chosen directory.
  • Loading branch information
supercomputer7 authored and timschumi committed Jun 1, 2024
1 parent d906255 commit a7aa843
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Userland/Utilities/tar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}

if (list || extract) {
NonnullOwnPtr<Stream> input_stream = TRY(Core::InputBufferedFile::create(TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read))));

if (!directory.is_empty())
TRY(Core::System::chdir(directory));

NonnullOwnPtr<Stream> input_stream = TRY(Core::InputBufferedFile::create(TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read))));

if (gzip)
input_stream = make<Compress::GzipDecompressor>(move(input_stream));

Expand Down

0 comments on commit a7aa843

Please sign in to comment.