63 std::cout <<
"Usage: " << g_progname <<
" [-opt] [file]" << std::endl;
64 std::cout <<
"Where -opt is one or more of:" << std::endl;
65 std::cout <<
" --count count the number of files in a .zip archive" << std::endl;
66 std::cout <<
" --count-directories count the number of files in a .zip archive" << std::endl;
67 std::cout <<
" --count-files count the number of files in a .zip archive" << std::endl;
68 std::cout <<
" --help show this help screen" << std::endl;
69 std::cout <<
" --version print the library version and exit" << std::endl;
70 std::cout <<
" --version-tool print the tool version and exit" << std::endl;
115 int main(
int argc,
char *argv[])
131 std::vector<std::string> files;
132 func_t function(func_t::UNDEFINED);
133 for(
int i(1); i < argc; ++i)
135 if(argv[i][0] ==
'-')
137 if(strcmp(argv[i],
"--help") == 0)
141 if(strcmp(argv[i],
"--version") == 0)
147 if(strcmp(argv[i],
"--version-tool") == 0)
154 if(strcmp(argv[i],
"--count") == 0)
156 function = func_t::COUNT;
158 else if(strcmp(argv[i],
"--count-directories") == 0)
160 function = func_t::COUNT_DIRECTORIES;
162 else if(strcmp(argv[i],
"--count-files") == 0)
164 function = func_t::COUNT_FILES;
169 files.push_back(argv[i]);
176 for(
auto it(files.begin()); it != files.end(); ++it)
182 std::cout << *it <<
": ";
184 std::cout << zf.
entries().size() << std::endl;
188 case func_t::COUNT_DIRECTORIES:
189 for(
auto it(files.begin()); it != files.end(); ++it)
195 std::cout << *it <<
": ";
199 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
201 if((*entry)->isDirectory())
206 std::cout << count << std::endl;
210 case func_t::COUNT_FILES:
211 for(
auto it(files.begin()); it != files.end(); ++it)
217 std::cout << *it <<
": ";
221 for(
auto entry(entries.begin()); entry != entries.end(); ++entry)
223 if(!(*entry)->isDirectory())
228 std::cout << count << std::endl;
233 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