mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
gunzip: Don't truncate output filename when input file suffix is omitted
Before this commit, `$ gunzip abcd` would incorrectly uncompress `abcd.gz` to `a` instead of to `abcd`.
This commit is contained in:
parent
e8ae0541d9
commit
5f639493f0
1 changed files with 6 additions and 4 deletions
|
@ -43,12 +43,14 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||||
for (auto filename : filenames) {
|
for (auto filename : filenames) {
|
||||||
|
|
||||||
String input_filename;
|
String input_filename;
|
||||||
if (filename.ends_with(".gz"))
|
String output_filename;
|
||||||
|
if (filename.ends_with(".gz")) {
|
||||||
input_filename = filename;
|
input_filename = filename;
|
||||||
else
|
output_filename = filename.substring_view(0, filename.length() - 3);
|
||||||
|
} else {
|
||||||
input_filename = String::formatted("{}.gz", filename);
|
input_filename = String::formatted("{}.gz", filename);
|
||||||
|
output_filename = filename;
|
||||||
const auto output_filename = filename.substring_view(0, filename.length() - 3);
|
}
|
||||||
|
|
||||||
auto input_stream_result = TRY(Core::InputFileStream::open_buffered(input_filename));
|
auto input_stream_result = TRY(Core::InputFileStream::open_buffered(input_filename));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue