// Executive.cpp // #include "Executive.h" #include "../FileMgr/FileMgr.h" #include "../FileMgr/FileSystem.h" #include #include void FileDates::usage() { std::cout << "\n Usage:"; std::cout << "\n path - must be first argument of command line"; std::cout << "\n pattern - may have multiple patterns of the form *.h"; std::cout << "\n /s - optional command to recurse into subdirectories"; std::cout << "\n\n"; } bool FileDates::showCmdLine(int argc, char** argv) { if (argc < 2) { std::cout << "\n missing path argument\n"; return false; } std::cout << "\n " << FileSystem::Path::getName(std::string(argv[0])); std::cout << "\n " << FileSystem::Path::getFullFileSpec(std::string(argv[1])); if (argc > 2) { std::cout << "\n "; } for (int i = 2; i < argc; ++i) { std::cout << argv[i]; if (i < argc - 1) { std::cout << ", "; } } std::cout << "\n"; } int FileDates::processCmdLine(int argc, char** argv) { if (argc < 2) { usage(); return 1; } showCmdLine(argc, argv); Path path = std::string(argv[1]); FileMgr fm(path, store_); for (int i = 2; i < argc; ++i) { if (argv[i][0] == '/') { if (argv[i][1] == 's' || argv[i][1] == 'S') { recurse_ = true; } else { std::cout << "\n Command Line Parse Error - incorrect option"; return 1; } } else { fm.addPattern(argv[i]); } } fm.search(true); fm.display(); return 0; } int main(int argc, char* argv[]) { FileDates fd; return fd.processCmdLine(argc, argv); }