47 sampleDepth (
int val_sampleDepth)
57 absSampleDepth (
int val_absSampleDepth)
67 sampleName (
const std::string& val_sampleName)
76 minDepth (std::size_t val_minDepth)
85 maxDepth (std::size_t val_maxDepth)
94 filePattern (
const std::string& val_filePattern)
103 fileRegex (
const std::string& val_fileRegex)
112 directoryPattern (
const std::string& val_directoryPattern)
121 directoryRegex (
const std::string& val_directoryRegex)
130 samplePattern (
const std::string& val_samplePattern)
139 samplePostfix (
const std::string& val_samplePostfix)
149 sampleRename (
const std::string& pattern,
const std::string& name)
158 extraNameComponent (
int val_relSampleDepth)
190 std::vector<std::string> hierarchy;
191 hierarchy.push_back (list.dirname());
193 std::map<std::string,SamplePtr> samples;
194 typedef std::map<std::string,SamplePtr>::iterator samplesIter;
195 recurse (samples, list, hierarchy);
196 for (samplesIter sample = samples.begin(), end = samples.end();
197 sample != end; ++ sample)
199 if (sample->second.get() != 0)
201 sh.add (sample->second);
210 recurse (std::map<std::string,SamplePtr>& samples,
DiskList& list,
211 const std::vector<std::string>& hierarchy)
const
213 using namespace msgScanDir;
218 std::unique_ptr<DiskList> sublist (list.openDir());
220 if (sublist.get() != 0)
224 ANA_MSG_DEBUG (
"directory does not match pattern, skipping directory " << list.path());
227 ANA_MSG_DEBUG (
"maxDepth exceeded, skipping directory " << list.path());
231 std::vector<std::string> subhierarchy = hierarchy;
232 subhierarchy.push_back (list.fileName());
233 recurse (samples, *sublist, subhierarchy);
241 std::vector<std::string> subhierarchy = hierarchy;
242 subhierarchy.push_back (list.fileName());
255 addSampleFile (std::map<std::string,SamplePtr>& samples,
256 const std::vector<std::string>& hierarchy,
257 const std::string& path)
const
274 for (std::size_t iter = 0, end =
sampleName.size();
275 iter != end && !done; ++ iter)
291 if (component.empty())
313 std::map<std::string,SamplePtr>::iterator iter
315 if (iter == samples.end())
328 std::string ScanDir ::
329 findPathComponent (
const std::vector<std::string>& hierarchy,
331 int relSampleDepth)
const
336 if (relSampleDepth < 0)
337 myindex = relSampleDepth + hierarchy.size();
338 if (std::size_t (myindex) >= hierarchy.size())
357 if (
split == std::string::npos)
369 if (
split != std::string::npos)
#define RCU_THROW_MSG(message)
a DiskList implementation for EOS
a DiskList implementation for local directories
an interface for listing directory contents, locally or on a file server
A class that manages a list of Sample objects.
A Sample based on a simple file list.
A smart pointer class that holds a single Sample object.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
void scan(TDirectory *td=0, int depth=0)
This module defines a variety of assert style macros.
bool match_expr(const std::regex &expr, const std::string &str)
returns: whether we can match the entire string with the regular expression guarantee: strong failure...
std::string glob_to_regexp(const std::string &glob)
returns: a string that is the regular expression equivalent of the given glob expression guarantee: s...
This module provides a lot of global definitions, forward declarations and includes that are used by ...
std::regex m_directoryPattern
the value set by directoryPattern, converted to a regular expression
ScanDir & sampleName(const std::string &val_sampleName)
a single sample name into which all found files should be placed.
std::string m_sampleName
the value set by sampleName
std::vector< std::pair< std::regex, std::string > >::const_iterator SampleRenameIter
the list of entries from sampleRename
bool m_samplePostfixEmpty
whether samplePostfix has been set to the empty string
std::regex m_filePattern
the value set by filePattern, converted to a regular expression
std::string findPathComponent(const std::vector< std::string > &hierarchy, int absSampleDepth, int relSampleDepth) const
find the path component at the given depth
int m_relSampleDepth
if this is negative it is the depth at which we take the sample name, counting from the end
int m_extraNameComponent
the depth set with extraNameComponent, or 0 otherwise
std::vector< std::pair< std::regex, std::string > > m_sampleRename
int m_absSampleDepth
if m_relSampleDepth is not negative, it is the depth at which we take the sample name,...
ScanDir & absSampleDepth(int val_absSampleDepth)
the index of the file hierarchy at which we gather the sample name.
std::size_t m_maxDepth
the value set by maxDepth
std::regex m_samplePattern
the value set by samplePattern, converted to a regular expression
ScanDir()
standard constructor
void recurse(std::map< std::string, SamplePtr > &samples, DiskList &list, const std::vector< std::string > &hierarchy) const
perform the recursive scanning of the directory tree
std::size_t m_minDepth
the value set by minDepth
void addSampleFile(std::map< std::string, SamplePtr > &samples, const std::vector< std::string > &hierarchy, const std::string &path) const
add the given file to the sample based on the hierarchy, creating the sample if necessary
std::regex m_samplePostfix
the value set by samplePostfix, converted to a regular expression