/////////////////////////////////////////////////////////////////////// // Executive.cpp - Illustrates how you can use fileInfo class to // // help with Project #3 implementation. // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2004 // /////////////////////////////////////////////////////////////////////// #include #include #include #include "fileInfo.h" using namespace std; //----< flexible title maker >----------------------------------------- template string title(const string &t) { string underline(t.length()+2,ch); return (string("\n ") + t + string("\n ") + underline + "\n"); } //----< search directory tree for files matching pattern string >------ void search(const std::string& path, const std::string& pattern) { vector dirs; fileInfo fi; fi.setPath(path.c_str()); std::string temp = std::string("files matching ") + pattern + std::string(" on path ") + fi.getPath() + std::string(" are:"); cout << title<'-'>(temp); // find directories using *.* if(fi.firstFile("*.*")) { if(fi.isDirectory() && fi.name() != "." && fi.name() != "..") dirs.push_back(fi.name()); } while(fi.nextFile()) { if(fi.isDirectory() && fi.name() != "." & fi.name() != "..") dirs.push_back(fi.name()); } fi.closeFile(); // now find files using file pattern if(fi.firstFile(pattern.c_str())) { fi.showData(cout); } while(fi.nextFile()) { fi.showData(cout); } fi.closeFile(); for(unsigned int i=0; i---------------------------------------- int main(int argc, char* argv[]) { cout << title<'='>("Demonstrating Use of fileInfo Object for Project #4"); if(argc==1) { cout << "\n please enter path on which to find files and file pattern(s)\n\n"; return 1; } cout << title<'-'>("Command arguments are:") << " "; for(int i=1; i