#include <FileHunter.hpp>
The specified criteria is threefold: 1. The File Specification. This is a path and/or file description which is the most important search criteria. For instance, the specification for a Rinex Obs file might be: /archive/ADMS%3n/RINEXOBS/S%2n%t%3jA.2y0 where the '%#char' elements denote fields such as year, day, station number, and so on. In this example, FileHunter is smart enough to search all station directories (ADMS401, ADMS402, etc) but it won't search any directories (or subdirectories) other than ones that match the initial specification. 2. Start and end times. If you simply call find(), FileHunter will return all files that match the specification. You can specify DayTimes to only return files whose dates (according to the file name) fall between those times. Note that you can tell find() to return the list of files ascending, descending, or unsorted (unsorted will return them in disk order). 3. Filters. Filters can be used on any field that your file specification includes. The most appropriate use of this is to filter for a certain set of stations, but it will allow you to filter ANY field (day, year, etc) that is in the file specification.
For more information about file specifications, see the comments in the FileSpec class. Also check the file FileSpecTest in the test subdirectory below this one for examples.
Limitations: If a file specification has two or more of the same field defined, only the first one is used. This is only if they repeat in a single directory or path. For instance, this would be ok: /ADMS%3n/FILE%3n but in this case: /ADMS%3n/%3j%3j only the first 3j would be used for the day field. Also, wildcards cannot be used. Sorry - it's a limitation of how regular expressions are used. Finally, if you specify a version field, all files matching will be reurned. You can either use extractField() on the returned files to determine the latest version or select the version you want returned by using setFilter().
Definition at line 109 of file FileHunter.hpp.
Public Types | |
| typedef std::pair< FileSpec::FileSpecType, std::vector< std::string > > | FilterPair |
| Pairs of FileSpecTypes and lists of strings for filtering the search results. | |
| enum | FileChunking { WEEK, DAY, HOUR, MINUTE } |
| This describes how the files to be searched are chunked i.e. More... | |
Public Member Functions | |
| FileHunter (const std::string &filespec) throw (FileHunterException) | |
| Constructs a FileHunter using a file specification. | |
| FileHunter (const FileSpec &filespec) throw (FileHunterException) | |
| Constructs a FileHunter using a FileSpec. | |
| FileHunter & | newHunt (const std::string &filespec) throw (FileHunterException) |
| Rather than building a new file hunter, this lets you change the filespec you're searching for. | |
| FileHunter & | newHunt (const FileSpec &filespec) throw (FileHunterException) |
| Changes the file spec you're searching for in FileHunter. | |
| FileHunter & | setFilter (const FileSpec::FileSpecType fst, const std::vector< std::string > &filter) throw (FileHunterException) |
| Filters FOR the strings in /a filter in the field specified by /a fst when searching. | |
| std::vector< std::string > | find (const gpstk::DayTime &start=gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime &end=gpstk::DayTime::END_OF_TIME, const FileSpec::FileSpecSortType fsst=FileSpec::ascending, enum FileChunking chunk=DAY) const throw (FileHunterException) |
| Does the searching for the files. | |
| void | dump (std::ostream &o) const |
| outputs the file spec into a semi-readable format | |
Protected Member Functions | |
| void | init (const std::string &filespec) throw (FileHunterException) |
| Shared code between the constructor and newHunt. | |
| std::vector< std::string > | searchHelper (const std::string &directory, const FileSpec &fs) const throw (FileHunterException) |
| Performs a search for the given file spec on the given directory. | |
| void | filterHelper (std::vector< std::string > &fileList, const FileSpec &fs) const throw (FileHunterException) |
| If there is a filter set, this will find the filtered items and set fileList to contain only those. | |
Protected Attributes | |
| std::vector< FileSpec > | fileSpecList |
| Holds the broken down list of the file specification for searching. | |
| std::vector< FilterPair > | filterList |
| Stores the list of things to filter for. | |
|
|
Pairs of FileSpecTypes and lists of strings for filtering the search results.
Definition at line 126 of file FileHunter.hpp. |
|
|
This describes how the files to be searched are chunked i.e. a DAY chunking means one file is written per day Definition at line 115 of file FileHunter.hpp. |
|
|
Constructs a FileHunter using a file specification. This can be a full or relative path and/or a file specification. See FileSpec for details on how to format a file specification.
Definition at line 69 of file FileHunter.cpp. References GPSTK_RETHROW. |
|
|
Constructs a FileHunter using a FileSpec.
Definition at line 82 of file FileHunter.cpp. References GPSTK_RETHROW. |
|
|
outputs the file spec into a semi-readable format
Definition at line 687 of file FileHunter.cpp. References Exception::dump(), and FileHunter::fileSpecList. Referenced by main(). |
|
||||||||||||
|
If there is a filter set, this will find the filtered items and set fileList to contain only those.
Definition at line 636 of file FileHunter.cpp. References gpstk::StringUtils::rightJustify(). |
|
||||||||||||||||||||
|
Does the searching for the files. Set /a start and /a end for specifying times of files (according to their file names) for returning.
Definition at line 136 of file FileHunter.cpp. References GPSTK_THROW, and slash. Referenced by FileFilterFrame::init(), and main(). |
|
|
Shared code between the constructor and newHunt.
Definition at line 336 of file FileHunter.cpp. References Exception::addText(), GPSTK_RETHROW, GPSTK_THROW, and slash. |
|
|
Changes the file spec you're searching for in FileHunter.
Definition at line 156 of file FileHunter.hpp. |
|
|
Rather than building a new file hunter, this lets you change the filespec you're searching for.
Definition at line 95 of file FileHunter.cpp. References GPSTK_RETHROW. Referenced by main(). |
|
||||||||||||
|
Performs a search for the given file spec on the given directory.
Definition at line 523 of file FileHunter.cpp. References Exception::addText(), GPSTK_THROW, gpstk::StringUtils::isLike(), and slash. |
|
||||||||||||
|
Filters FOR the strings in /a filter in the field specified by /a fst when searching.
Definition at line 109 of file FileHunter.cpp. Referenced by FileFilterFrame::init(), and main(). |
|
|
Holds the broken down list of the file specification for searching.
Definition at line 221 of file FileHunter.hpp. Referenced by FileHunter::dump(). |
|
|
Stores the list of things to filter for.
Definition at line 224 of file FileHunter.hpp. |
1.3.9.1