00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "globPattern.h"
00020
00021 int
00022 main(int argc, char *argv[]) {
00023 if (argc != 2 && argc != 3) {
00024 cerr
00025 << "test_glob \"pattern\" [from-directory]\n\n"
00026 << "Attempts to match the pattern against each of the files in the\n"
00027 << "indicated directory if specified, or the current directory\n"
00028 << "otherwise. Reports all of the matching files. This is,\n"
00029 << "of course, exactly the normal behavior of the shell; this test\n"
00030 << "program merely exercises the Panda GlobPattern object, which\n"
00031 << "duplicates the shell functionality.\n\n";
00032 exit(1);
00033 }
00034
00035 GlobPattern pattern(argv[1]);
00036 Filename from_directory;
00037 if (argc == 3) {
00038 from_directory = argv[2];
00039 }
00040
00041 vector_string results;
00042 int num_matched = pattern.match_files(results, from_directory);
00043
00044 cerr << num_matched << " results:\n";
00045 vector_string::const_iterator si;
00046 for (si = results.begin(); si != results.end(); ++si) {
00047 cerr << " " << *si << "\n";
00048 }
00049
00050 return (0);
00051 }
00052
00053