2024-03-28 17:40:14 -05:00
|
|
|
#include "miniz.h"
|
2023-09-18 07:36:07 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-03-28 17:40:14 -05:00
|
|
|
#include <string.h>
|
2023-09-18 07:36:07 -05:00
|
|
|
|
2024-03-28 17:40:14 -05:00
|
|
|
int main(int argc, char *argv[])
|
2023-09-18 07:36:07 -05:00
|
|
|
{
|
2024-03-28 17:40:14 -05:00
|
|
|
if (argc < 3) {
|
|
|
|
printf("Usage: %s zip_archive file1 [file2 ...]\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the zip file for writing
|
|
|
|
mz_bool status;
|
|
|
|
mz_zip_archive zip_archive;
|
|
|
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
|
|
|
printf("Creating a zip archive named %s.\n", argv[1]);
|
|
|
|
status = mz_zip_writer_init_file(&zip_archive, argv[1], 0);
|
|
|
|
if (!status) {
|
|
|
|
printf("Error: could not open zip file for writing.\n%s\n", mz_error(status));
|
|
|
|
return 1;
|
|
|
|
}
|
2023-09-18 07:36:07 -05:00
|
|
|
|
2024-03-28 17:40:14 -05:00
|
|
|
// Add files to the zip archive
|
|
|
|
for (int i = 2; i < argc; ++i)
|
|
|
|
mz_zip_writer_add_file(&zip_archive, argv[i], argv[i], NULL, 0, MZ_DEFAULT_COMPRESSION);
|
2023-09-18 07:36:07 -05:00
|
|
|
|
2024-03-28 17:40:14 -05:00
|
|
|
// Close the zip file
|
|
|
|
mz_zip_writer_finalize_archive(&zip_archive);
|
|
|
|
mz_zip_writer_end(&zip_archive);
|
2023-09-18 07:36:07 -05:00
|
|
|
|
2024-03-28 17:40:14 -05:00
|
|
|
return 0;
|
2024-06-07 10:38:21 -05:00
|
|
|
}
|