Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/test_glob.cxx

Go to the documentation of this file.
00001 // Filename: test_glob.cxx
00002 // Created by:  drose (30May00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 

Generated on Fri May 2 00:43:45 2003 for Panda by doxygen1.3