59 std::cout <<
"Usage: " << g_progname <<
" [-opt] [file]" << std::endl;
60 std::cout <<
"Where -opt is one or more of:" << std::endl;
61 std::cout <<
" --count count the number of files in a .zip archive" << std::endl;
62 std::cout <<
" --count-directories count the number of files in a .zip archive" << std::endl;
63 std::cout <<
" --count-files count the number of files in a .zip archive" << std::endl;
64 std::cout <<
" --help show this help screen" << std::endl;
65 std::cout <<
" --version print the library version and exit" << std::endl;
66 std::cout <<
" --version-tool print the tool version and exit" << std::endl;
111 int main(
int argc,
char *argv[])
127 std::vector<std::string> files;
128 func_t function(func_t::UNDEFINED);
129 for(
int i(1); i < argc; ++i)
131 if(argv[i][0] ==
'-')
133 if(strcmp(argv[i],
"--help") == 0)
137 if(strcmp(argv[i],
"--version") == 0)
143 if(strcmp(argv[i],
"--version-tool") == 0)
150 if(strcmp(argv[i],
"--count") == 0)
152 function = func_t::COUNT;
154 else if(strcmp(argv[i],
"--count-directories") == 0)
156 function = func_t::COUNT_DIRECTORIES;
158 else if(strcmp(argv[i],
"--count-files") == 0)
160 function = func_t::COUNT_FILES;
165 files.push_back(argv[i]);
172 for(
auto it(files.begin()); it != files.end(); ++it)
178 std::cout << *it <<
": ";
180 std::cout << zf.
entries().size() << std::endl;
184 case func_t::COUNT_DIRECTORIES:
185 for(
auto it(files.begin()); it != files.end(); ++it)
191 std::cout << *it <<
": ";
195 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
197 if((*entry)->isDirectory())
202 std::cout << count << std::endl;
206 case func_t::COUNT_FILES:
207 for(
auto it(files.begin()); it != files.end(); ++it)
213 std::cout << *it <<
": ";
217 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
219 if(!(*entry)->isDirectory())
224 std::cout << count << std::endl;
229 std::cerr <<
g_progname <<
":error: undefined function." << std::endl;
The ZipFile class represents a collection of files.
Count the number of files in a Zip archive.
int main(int argc, char *argv[])
char const * getVersion()
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
char * g_progname
Name of the program.
func_t
The function to apply.
Define the zipios::ZipFile class.
Count the number of regular files in a Zip archive.
void usage()
Usage of the zipios tool.
Count the number of directories in a Zip archive.
#define ZIPIOS_VERSION_STRING
std::vector< pointer_t > vector_t