48 std::cout <<
"Usage: " <<
g_progname <<
" <output>[.zip] <input-dir>" << std::endl;
49 std::cout <<
"This tool creates a zip file from a directory or a file." << std::endl;
50 std::cout <<
"This is a way to exercise the library." << std::endl;
59int main(
int argc,
char *argv[])
77 for(
int i(1); i < argc; ++i)
79 if(strcmp(argv[i],
"-h") == 0
80 || strcmp(argv[i],
"--help") == 0)
84 if(strcmp(argv[i],
"-V") == 0
85 || strcmp(argv[i],
"--version") == 0)
90 if(strcmp(argv[i],
"--level") == 0)
95 std::cerr <<
"error: the --level option must be followed by a level.";
98 if(strcmp(argv[i],
"default") == 0)
102 else if(strcmp(argv[i],
"smallest") == 0)
106 else if(strcmp(argv[i],
"fastest") == 0)
110 else if(strcmp(argv[i],
"none") == 0)
121 <<
"error: the --level parameter expects one of"
122 " \"default\", \"smallest\", \"fastest\", \"none\""
123 " or a number between "
132 else if(strcmp(argv[i],
"--limit") == 0)
137 std::cerr <<
"error: the --limit option must be followed by a limit.";
140 if(strcmp(argv[i],
"default") == 0)
146 limit = std::atoi(argv[i]);
159 std::cerr <<
"error: unknown command line option \""
161 <<
"\". Try --help for additional information.";
168 std::cerr <<
"error: missing input directory name on command line.\n";
206 std::string zipname(out);
207 if(zipname.find(
".zip", zipname.length() - 4) == std::string::npos)
211 std::ofstream output(zipname, std::ios_base::binary);
A collection generated from reading a directory.
void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method)
Change the storage method to the specified value.
void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level)
Change the compression level to the specified value.
int CompressionLevel
The compression level to be used to save an entry.
static CompressionLevel const COMPRESSION_LEVEL_MINIMUM
static CompressionLevel const COMPRESSION_LEVEL_MAXIMUM
static CompressionLevel const COMPRESSION_LEVEL_DEFAULT
static CompressionLevel const COMPRESSION_LEVEL_NONE
static CompressionLevel const COMPRESSION_LEVEL_FASTEST
static CompressionLevel const COMPRESSION_LEVEL_SMALLEST
static void saveCollectionToArchive(std::ostream &os, FileCollection &collection, std::string const &zip_comment=std::string())
Create a Zip archive from the specified FileCollection.
Define the zipios::DirectoryCollection class.
int main(int argc, char *argv[])
Define the zipios::ZipFile class.
#define ZIPIOS_VERSION_STRING