64 std::cout <<
"Usage: " <<
g_progname <<
" [-opt] [file]" << std::endl;
65 std::cout <<
"Where -opt is one or more of:" << std::endl;
66 std::cout <<
" --count count the number of files in a .zip archive" << std::endl;
67 std::cout <<
" --count-directories count the number of files in a .zip archive" << std::endl;
68 std::cout <<
" --count-files count the number of files in a .zip archive" << std::endl;
69 std::cout <<
" --help show this help screen" << std::endl;
70 std::cout <<
" --libzipios-version print the library version and exit" << std::endl;
71 std::cout <<
" --version print this tool's version and exit" << std::endl;
116int main(
int argc,
char *argv[])
136 std::vector<std::string> files;
138 for(
int i(1); i < argc; ++i)
140 if(argv[i][0] ==
'-')
142 if(strcmp(argv[i],
"--help") == 0)
146 if(strcmp(argv[i],
"--libzipios-version") == 0)
152 if(strcmp(argv[i],
"--version") == 0)
159 if(strcmp(argv[i],
"--count") == 0)
163 else if(strcmp(argv[i],
"--count-directories") == 0)
167 else if(strcmp(argv[i],
"--count-files") == 0)
174 files.push_back(argv[i]);
181 for(
auto it(files.begin()); it != files.end(); ++it)
186 std::cout << *it <<
": ";
189 std::cout << zf.
entries().size() << std::endl;
194 for(
auto it(files.begin()); it != files.end(); ++it)
199 std::cout << *it <<
": ";
204 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
206 if((*entry)->isDirectory())
211 std::cout << count << std::endl;
216 for(
auto it(files.begin()); it != files.end(); ++it)
221 std::cout << *it <<
": ";
226 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
228 if(!(*entry)->isDirectory())
233 std::cout << count << std::endl;
238 std::cerr <<
g_progname <<
":error: undefined function." << std::endl;
246 std::cerr <<
g_progname <<
":error: an exception occurred: "
247 << e.what() << std::endl;
Base exception of the zipios environment.
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
std::vector< pointer_t > vector_t
The ZipFile class represents a collection of files.
void usage()
Usage of the zipios tool.
func_t
The function to apply.
@ UNDEFINED
Still undefined.
@ COUNT
Count the number of files in a Zip archive.
@ COUNT_DIRECTORIES
Count the number of directories in a Zip archive.
@ COUNT_FILES
Count the number of regular files in a Zip archive.
char * g_progname
Name of the program.
char const * getVersion()
Define the zipios::ZipFile class.
#define ZIPIOS_VERSION_STRING
int main(int argc, char *argv[])
Various exceptions used throughout the Zipios library, all based on zipios::Exception.