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

FileScanner Class Reference

This scans a path and looks for CMT packages. More...

List of all members.


Public Methods

? FileScanner ()
bool? scan_path (const cmt_string& path, actor& a)

Private Methods

void? scan_path (const cmt_string& path, int level, actor& a)

Private Attributes

bool? _running
int? _level

Detailed Description

This scans a path and looks for CMT packages.

Whenever it finds one, it applies the specified actor to it.

Definition at line 10 of file cmtshowclients.cxx.


Constructor & Destructor Documentation

FileScanner::FileScanner ( )
?

Definition at line 39 of file cmtshowclients.cxx.

00041 {
00042   _running = false;
00043   _level = 0;
00044 }

Member Function Documentation

void FileScanner::scan_path ( const cmt_string & path,
int level,
actor & a?) [private]
?

Definition at line 62 of file cmtshowclients.cxx.

00064 {
00065     //
00066     // Only do something if it is a directory.
00067     //
00068 
00069   if (!CmtSystem::test_directory (path)) return;
00070 
00071   CmtSystem::cmt_string_vector list;
00072 
00073   CmtSystem::scan_dir (path, list);
00074 
00075   if (list.size () == 0) return;
00076 
00077   _level++;
00078 
00079     // Will be set if at least one directory is a version directory
00080   bool has_package = false;
00081 
00082   cmt_string pack;
00083   CmtSystem::basename (path, pack);
00084 
00085   int i;
00086   for (i = 0; i < list.size (); i++)
00087     {
00088       const cmt_string& name = list[i];
00089 
00090         //cout << "scan> level=" << level << " name=" << name;
00091 
00092       cmt_string version;
00093       CmtSystem::basename (name, version);
00094 
00095         //
00096         //  All entries at this level may be "legal" version directories.
00097         //
00098         //  So we go down but no more then one level deep.
00099         //  The next level we request that the entry is a version
00100         //  and that there is a mgr/requirements file below.
00101         //
00102 
00103       if (level == 0)
00104         {
00105             //cout << " -> down" << endl;
00106           scan_path (name, level + 1, a);
00107         }
00108       else if (CmtSystem::is_version_directory (version))
00109         {
00110           cmt_string req;
00111 
00112           req = name;
00113           req += CmtSystem::file_separator ();
00114           req += "cmt";
00115           req += CmtSystem::file_separator ();
00116           req += "requirements";
00117 
00118           if (CmtSystem::test_file (req))
00119             {
00120                 //cout << " -> cmt" << endl;
00121 
00122               a.run (pack, version, path);
00123 
00124               has_package = true;
00125             }
00126           else
00127             {
00128                 //cout << " -> no cmt" << endl;
00129               req = name;
00130               req += CmtSystem::file_separator ();
00131               req += "mgr";
00132               req += CmtSystem::file_separator ();
00133               req += "requirements";
00134 
00135               if (CmtSystem::test_file (req))
00136                 {
00137                     //cout << " -> cmt" << endl;
00138 
00139                   a.run (pack, version, path);
00140 
00141                   has_package = true;
00142                 }
00143               else
00144                 {
00145                     //cout << " -> no mgr" << endl;
00146                 }
00147             }
00148         }
00149       else
00150         {
00151             //cout << " -> stop" << endl;
00152         }
00153     }
00154 
00155   if (has_package)
00156     {
00157         //
00158         // At least one version was found here.
00159         //
00160       scan_path (path, 0, a);
00161     }
00162 
00163   _level--;
00164 }

bool FileScanner::scan_path ( const cmt_string & path,
actor & a?)
?

Definition at line 47 of file cmtshowclients.cxx.

Referenced by main().

00049 {
00050   if (_running) return (false);
00051 
00052   _level = 0;
00053   _running = true;
00054   scan_path (path, 0, a);
00055   _running = false;
00056   _level = 0;
00057 
00058   return (true);
00059 }

Member Data Documentation

int FileScanner::_level [private]
?

Definition at line 34 of file cmtshowclients.cxx.

bool FileScanner::_running [private]
?

Definition at line 33 of file cmtshowclients.cxx.


The documentation for this class was generated from the following file:
Generated at Fri Apr 12 16:18:16 2002 for cmtgrapher by 1.2.3 written by , ??1997-2000