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
00020 void SetKey(const std::string &value);
00021
00022
00023 void SetRunRange(int first_run, int last_run);
00024
00025
00026 void SetRunPosition(int beg_pos, int length);
00027
00028
00029 int SearchPath(const std::string &path) { return Search(path, 0); }
00030
00031 void SetRecursiveDepth(short depth);
00032
00033
00034 void SetIndexFile(const std::string &index_file);
00035
00036
00037
00038
00039
00040
00041 unsigned int GetNFiles() const { return fFiles.size(); }
00042
00043
00044 std::string GetFile(int index) const;
00045
00046
00047 double FileSize(int index = -1) const;
00048
00049
00050 void Print() const;
00051
00052 private:
00053
00054
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
00076 std::vector<std::string> fKeys;
00077
00078
00079 std::vector<std::string> fNames;
00080
00081
00082 std::vector<std::string> fFiles;
00083
00084
00085 std::vector<std::string> fIndex;
00086 };
00087 }
00088 #endif