mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
gunzip: Use a buffered file to read from the input file
This commit is contained in:
parent
5aaefe4e62
commit
13bc999173
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/trflynn89
Commit: 13bc999173
Pull-request: https://github.com/SerenityOS/serenity/pull/18075
1 changed files with 5 additions and 3 deletions
|
@ -11,7 +11,7 @@
|
|||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::File> input_stream, Stream& output_stream)
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Stream> input_stream, Stream& output_stream)
|
||||
{
|
||||
auto gzip_stream = Compress::GzipDecompressor { move(input_stream) };
|
||||
|
||||
|
@ -51,10 +51,12 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
output_filename = filename;
|
||||
}
|
||||
|
||||
auto input_stream_result = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read));
|
||||
auto input_file = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read));
|
||||
auto buffered_input_file = TRY(Core::BufferedFile::create(move(input_file)));
|
||||
|
||||
auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
|
||||
|
||||
TRY(decompress_file(move(input_stream_result), *output_stream));
|
||||
TRY(decompress_file(move(buffered_input_file), *output_stream));
|
||||
|
||||
if (!keep_input_files)
|
||||
TRY(Core::System::unlink(input_filename));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue