Ignore:
Timestamp:
Dec 16, 2011, 4:19:31 AM (10 years ago)
Author:
Peter Johansson
Message:

new classes DirectoryUtil? and CacheRemover?. remove obsoleted cache files. closes #510

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r1290 r1423  
    2424#include "Alias.h"
    2525#include "Configuration.h"
     26#include "DirectoryUtil.h"
    2627#include "File.h"
    2728#include "html_utility.h"
     
    3940#include <iostream>
    4041#include <iterator>
    41 #include <list>
    4242#include <map>
    4343#include <sstream>
     44#include <vector>
    4445
    45 #include <cerrno> // Needed to check error state below.
    46 #include <dirent.h>
    4746#include <sys/stat.h>
    4847
     
    5150
    5251
    53   Directory::Directory(const unsigned int level, const std::string& path, 
     52  Directory::Directory(const unsigned int level, const std::string& path,
    5453                       const std::string& output, const std::string& project)
    5554    : Node(level,path,output,project)
     
    5958      output_dir_+='/';
    6059
    61     using namespace std;
    62     DIR* directory=opendir(path.c_str());    // C API from dirent.h
    63     if (!directory)
    64       throw NodeException("ERROR: opendir() failed; " + path +
    65                           " is not a directory");
    66     list<string> entries;
    67     struct dirent* entry;
    68     errno=0;  // Global variable used by C to track errors, from errno.h
    69     while ((entry=readdir(directory)))       // C API from dirent.h
    70       entries.push_back(string(entry->d_name));
    71     if (errno)
    72       throw NodeException("ERROR: readdir() failed on " + path);
    73     closedir(directory);
     60    DirectoryUtil dir(path);
    7461
    7562    SVN* svn=SVN::instance();
    76     for (list<string>::iterator i=entries.begin(); i!=entries.end(); ++i)
    77       if ((*i)!=string(".") && (*i)!=string("..") && (*i)!=string(".svn")) {
    78         string fullpath(path_+'/'+(*i));
    79         switch (svn->version_controlled(fullpath)) {
     63    for (DirectoryUtil::const_iterator i=dir.begin(); i!=dir.end(); ++i) {
     64      std::string fn = file_name(i->path());
     65      if (fn!="." && fn!=".." && fn!=".svn") {
     66        const std::string& fullpath = i->path();
     67        switch(svn->version_controlled(fullpath)) {
    8068        case SVN::uptodate:
    8169          struct stat nodestat;                // C api from sys/stat.h
     
    9179        }
    9280      }
     81    }
    9382    std::sort(daughters_.begin(), daughters_.end(), NodePtrLess());
    9483  }
Note: See TracChangeset for help on using the changeset viewer.