Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FileFinder.h

Go to the documentation of this file.
00001 #ifndef ROOTUTIL_FILEFINDER_H
00002 #define ROOTUTIL_FILEFINDER_H
00003 
00004 #include <fstream>
00005 #include <iostream>
00006 #include <string>
00007 #include <vector>
00008 
00009 namespace RootUtil
00010 {
00011    class FileFinder
00012    {
00013       
00014    public:
00015       
00016       FileFinder(); 
00017       ~FileFinder();  
00018       
00019       // file name must contain substring = value
00020       void SetKey(const std::string &value);
00021       
00022       // select run numbers in this range
00023       void SetRunRange(int first_run, int last_run);
00024       
00025       // in string filename run number starts at beg_pos for length characters
00026       void SetRunPosition(int beg_pos, int length);
00027 
00028       // recursively search path for matching files, return # of matching files
00029       int SearchPath(const std::string &path) { return Search(path, 0); }
00030 
00031       void SetRecursiveDepth(short depth);
00032       
00033       // search only for files from index file
00034       void SetIndexFile(const std::string &index_file);
00035       
00036       //---------------------------------------------------------------------------
00037       // const methods below this line
00038       //---------------------------------------------------------------------------
00039 
00040       // number of found files that meet search criteria
00041       unsigned int GetNFiles() const { return fFiles.size(); }
00042       
00043       // get full file path at this index
00044       std::string GetFile(int index) const;
00045       
00046       // get file size at this index, if index < 0 return size of all files
00047       double FileSize(int index = -1) const;
00048       
00049       // print config parameters
00050       void Print() const;
00051       
00052    private:
00053 
00054       // recursively search path for matching files
00055       int Search(std::string path, short depth);
00056       
00057       bool FindMatch(const std::string &file_name);
00058       
00059       bool CheckFileName(const std::string &name, const std::string &path);
00060 
00061       int GetRunNumber(const std::string &filename) const;
00062       
00063    private:
00064       
00065       int fFirstRun;
00066       int fLastRun;
00067       
00068       int fRunNumberPos;
00069       int fRunNumberLen;
00070 
00071       int fRecursiveDepth;
00072 
00073       bool fUseIndex;
00074 
00075       // value is required matching substring
00076       std::vector<std::string> fKeys;
00077       
00078       // file names
00079       std::vector<std::string> fNames;
00080 
00081       // full file path
00082       std::vector<std::string> fFiles;
00083 
00084       // file names
00085       std::vector<std::string> fIndex;
00086    };
00087 }
00088 #endif

Generated on Mon Feb 15 11:06:41 2010 for loon by  doxygen 1.3.9.1