summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjz19910 <matthias291999@gmail.com>2022-01-03 02:10:34 -0700
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-01-04 10:59:42 +0000
commit7c05db19a1a0248eedbe8b19f5efc321dfa473de (patch)
treee1397125882cfeb259005abfc25085a6b2784627
parenteacbbca4c45ef5ec4c7b657a6895dc7e9555c59e (diff)
downloadserenity-7c05db19a1a0248eedbe8b19f5efc321dfa473de.zip
zip: Port to LibMain :^)
-rw-r--r--Userland/Utilities/CMakeLists.txt2
-rw-r--r--Userland/Utilities/zip.cpp11
2 files changed, 4 insertions, 9 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt
index 9203f2d4ed..d31bd03adf 100644
--- a/Userland/Utilities/CMakeLists.txt
+++ b/Userland/Utilities/CMakeLists.txt
@@ -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)
diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp
index 0f68c8f304..6dce8adc18 100644
--- a/Userland/Utilities/zip.cpp
+++ b/Userland/Utilities/zip.cpp
@@ -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) {