50 std::cout <<
"Usage: " <<
g_progname <<
" <output>[.zip] <input-dir>" << std::endl;
51 std::cout <<
"This tool creates a zip file from a directory or a file." << std::endl;
52 std::cout <<
"This is a way to exercise the library." << std::endl;
61int main(
int argc,
char *argv[])
79 for(
int i(1); i < argc; ++i)
81 if(strcmp(argv[i],
"-h") == 0
82 || strcmp(argv[i],
"--help") == 0)
86 if(strcmp(argv[i],
"-V") == 0
87 || strcmp(argv[i],
"--version") == 0)
92 if(strcmp(argv[i],
"--level") == 0)
97 std::cerr <<
"error: the --level option must be followed by a level.";
100 if(strcmp(argv[i],
"default") == 0)
104 else if(strcmp(argv[i],
"smallest") == 0)
108 else if(strcmp(argv[i],
"fastest") == 0)
112 else if(strcmp(argv[i],
"none") == 0)
123 <<
"error: the --level parameter expects one of"
124 " \"default\", \"smallest\", \"fastest\", \"none\""
125 " or a number between "
134 else if(strcmp(argv[i],
"--limit") == 0)
139 std::cerr <<
"error: the --limit option must be followed by a limit.";
142 if(strcmp(argv[i],
"default") == 0)
148 limit = std::atoi(argv[i]);
161 std::cerr <<
"error: unknown command line option \""
163 <<
"\". Try --help for additional information.";
170 std::cerr <<
"error: missing input directory name on command line.\n";
208 std::string zipname(out);
209 if(zipname.find(
".zip", zipname.length() - 4) == std::string::npos)
213 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