- Timestamp:
- Dec 30, 2005, 6:41:33 PM (17 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Directory.cc
r16 r18 7 7 #include <iostream> 8 8 #include <iterator> 9 #include <list> 9 10 10 11 #include <errno.h> // Needed to check error state below. … … 24 25 exit(1); 25 26 } 26 vector<string> entries;27 list<string> entries; 27 28 struct dirent* entry; 28 29 errno=0; // Global variable used by C to track errors. … … 37 38 38 39 // Jari, change this to some STL algo? 39 for ( vector<string>::iterator i=entries.begin(); i!=entries.end(); i++)40 if ((*i)!=string(".") && (*i)!=string("..") ) {40 for (list<string>::iterator i=entries.begin(); i!=entries.end(); i++) 41 if ((*i)!=string(".") && (*i)!=string("..") && (*i)!=string(".svn")) { 41 42 /// Jari, should test if directory in some other way 42 DIR* dirtest=opendir(i->c_str()); 43 string fullpath(path_+'/'+(*i)); 44 DIR* dirtest=opendir(fullpath.c_str()); 43 45 if (!dirtest) 44 daughters_.push_back(new File( *i));46 daughters_.push_back(new File(fullpath)); 45 47 else 46 daughters_.push_back(new Directory( *i));48 daughters_.push_back(new Directory(fullpath)); 47 49 } 48 50 } … … 52 54 { 53 55 // Jari, change this to some STL algo? 54 for (std:: vector<Node*>::iterator i=daughters_.begin();56 for (std::list<Node*>::iterator i=daughters_.begin(); 55 57 i!=daughters_.end(); i++) 56 58 delete *i; … … 62 64 stats_.reset(); 63 65 64 for (size_t i = 0; i<daughters_.size(); i++) 65 stats_ += daughters_[i]->parse(); 66 for (std::list<Node*>::iterator i=daughters_.begin(); 67 i!=daughters_.end(); i++) 68 stats_ += (*i)->parse(); 66 69 return stats_; 67 70 } … … 70 73 void Directory::print(void) { 71 74 // Jari, temporary using this to print directory tree 72 std::cout << "-------------- Directory '" << path_ << "'" << std::endl;73 75 for_each(daughters_.begin(),daughters_.end(), std::mem_fun(&Node::print)); 74 76 } 75 77 78 79 void Directory::purge(void) { 80 for (std::list<Node*>::iterator i=daughters_.begin(); i!=daughters_.end(); ) 81 if (!((*i)->subversion_controlled())) { 82 delete *i; 83 i=daughters_.erase(i); 84 } 85 else { 86 (*i)->purge(); 87 i++; 88 } 89 } 90 76 91 }} // end of namespace svnstat and namespace theplu -
trunk/lib/Directory.h
r14 r18 6 6 #include "Node.h" 7 7 8 #include <vector> 8 #include <list> 9 #include <string> 9 10 10 11 namespace theplu{ … … 20 21 /// @brief Constructor 21 22 /// 23 /// Recursively create a directory tree starting from \a 24 /// path. Nodes named '.', '..', and '.svn' are ignored and not 25 /// traversed. 26 /// 22 27 Directory(const std::string& path); 23 28 … … 31 36 void print(void); 32 37 38 void purge(void); 39 33 40 private: 34 41 /// … … 37 44 Directory(const Directory&); 38 45 39 std:: vector<Node*> daughters_;46 std::list<Node*> daughters_; 40 47 }; 41 48 -
trunk/lib/Node.cc
r16 r18 37 37 } 38 38 39 39 40 bool Node::subversion_controlled(void) const { 41 std::string system_call = "svn proplist " + path_ + ">&/dev/null"; 42 return !system(system_call.c_str()); 43 } 44 40 45 }} // end of namespace svnstat and namespace theplu -
trunk/lib/Node.h
r16 r18 37 37 virtual void print(void)=0; 38 38 39 inline virtual void purge(void) { /* Nothing to be done */ }; 40 39 41 /// 40 /// Check if the node is under subversion control. If node 41 /// is under subversion control, information about node is 42 /// parsed from the 'svn info' output. 43 /// 42 /// Check if the node is under subversion control. This is done by 43 /// checking the return status of 'svn proplist <Node>. 44 44 /// 45 45 /// @return True if subversion controlled, false otherwise. 46 46 /// 47 bool subversion_controlled(void) ;47 bool subversion_controlled(void) const; 48 48 49 49 protected:
Note: See TracChangeset
for help on using the changeset viewer.