zip: Port to LibMain :^)

This commit is contained in:
mjz19910 2022-01-03 02:10:34 -07:00 committed by Brian Gianforcaro
parent eacbbca4c4
commit 7c05db19a1
Notes: sideshowbarker 2024-07-17 21:42:42 +09:00
2 changed files with 4 additions and 9 deletions

View file

@ -156,7 +156,7 @@ target_link_libraries(uptime LibMain)
target_link_libraries(userdel LibMain)
target_link_libraries(usermod LibMain)
target_link_libraries(utmpupdate LibMain)
target_link_libraries(zip LibArchive LibCompress LibCrypto)
target_link_libraries(zip LibArchive LibCompress LibCrypto LibMain)
target_link_libraries(cpp-lexer LibCpp)
target_link_libraries(cpp-parser LibCpp LibGUI)
target_link_libraries(cpp-preprocessor LibCpp LibGUI)

View file

@ -13,7 +13,7 @@
#include <LibCore/FileStream.h>
#include <LibCrypto/Checksum/CRC32.h>
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
const char* zip_path;
Vector<StringView> source_paths;
@ -25,7 +25,7 @@ int main(int argc, char** argv)
args_parser.add_positional_argument(source_paths, "Input files to be archived", "files", Core::ArgsParser::Required::Yes);
args_parser.add_option(recurse, "Travel the directory structure recursively", "recurse-paths", 'r');
args_parser.add_option(force, "Overwrite existing zip file", "force", 'f');
args_parser.parse(argc, argv);
args_parser.parse(arguments);
String zip_file_path { zip_path };
if (Core::File::exists(zip_file_path)) {
@ -37,15 +37,10 @@ int main(int argc, char** argv)
}
}
auto file_stream_or_error = Core::OutputFileStream::open(zip_file_path);
if (file_stream_or_error.is_error()) {
warnln("Failed to open zip file: {}", file_stream_or_error.error());
return 1;
}
auto file_stream = TRY(Core::OutputFileStream::open(zip_file_path));
outln("Archive: {}", zip_file_path);
auto file_stream = file_stream_or_error.value();
Archive::ZipOutputStream zip_stream { file_stream };
auto add_file = [&](String path) {