31 m_filteredExtensions(0),
33 m_waitOnDirFlag(false),
46 static const char M[] =
"ossimFileWalker::walk";
54 std::vector<ossimFilename>::const_iterator i = files.begin();
55 while ( i != files.end() )
74 <<
"Making the job for: " << (*i) << std::endl;
78 std::shared_ptr<ossimFileWalkerJob> job =
83 job->setCallback( std::make_shared<ossimFileWalkerJobCallback>() );
106 << M <<
" WARNING: file: \""<< file <<
"\" does not exist" << std::endl;
118 if (
m_jobQueue->hasJobsToProcess() == false )
134 static const char M[] =
"ossimFileWalker::walk";
146 if ( rootFile.
isDir() )
154 if (
m_jobQueue->hasJobsToProcess() == false )
172 << M <<
" WARNING: file: \""<< rootFile <<
"\" does not exist" << std::endl;
184 static const char M[] =
"ossimFileWalker::walkDir";
188 << M <<
" entered...\n" <<
"processing dir: " << dir <<
"\n";
192 std::vector<ossimFilename> dirs;
195 std::vector<ossimFilename> files;
199 bool ossimDirectoryStatus = d.
open(dir);
202 if ( ossimDirectoryStatus )
230 std::vector<ossimFilename>::const_iterator i = files.begin();
231 while (i != files.end())
239 std::shared_ptr<ossimFileWalkerJob> job =
244 job->setCallback( std::make_shared<ossimFileWalkerJobCallback>() );
271 if (
m_jobQueue->hasJobsToProcess() == false )
283 while (i != dirs.end())
320 else if ( file[file.
size()-1] ==
'~' )
346 <<
"ossimFileWalker::isFiltered file " << (result?
"filtered: ":
"not filtered: ")
361 std::string::size_type firstDotPos = f.
find(
'.');
362 if ( firstDotPos == 0 )
366 else if ( firstDotPos != std::string::npos )
369 std::string::size_type lastDotPos = f.
find_last_of(
'.');
370 if ( lastDotPos != std::string::npos )
379 std::string::size_type lastSlashPos = f2.
find_last_of(
'/');
381 if (lastSlashPos != std::string::npos)
383 if ( (lastSlashPos+1) == lastDotPos )
497 : m_fileProcessor( fpi ),
void dumpFilteredExtensionList() const
Dumps filtered image extenstions to std out.
void setFileProcessor(ossimFileProcessorInterface *fpi)
Sets ossimFileProcessorInterfacecallback method to process files.
void setRecurseFlag(bool flag)
Sets recurse flag.
virtual void run()
Defines pure virtual ossimJob::start.
bool getFirst(ossimFilename &filename, int flags=OSSIM_DIR_DEFAULT)
ossimFilename expand() const
Method to do file name expansion.
ossimFileWalkerJob(ossimFileProcessorInterface *fpi, const ossimFilename &file)
Constructor that takes file processor pointer and file.
const std::vector< std::string > & getFilteredExtensions() const
ossimFileProcessorInterface * m_fileProcessor
Callback to method to process a file.
bool isFiltered(const ossimFilename &f) const
Convenience method for file walker code to check file to see is it should be processed.
static void sleepInMicroSeconds(ossim_uint64 micros)
Utility method to allow one to sleep in microseconds.
bool getNext(ossimFilename &filename) const
std::shared_ptr< ossimJobMultiThreadQueue > m_jobQueue
void walkDir(const ossimFilename &dir)
Processes files in directory.
This allocates a thread pool used to listen on a shared job queue.
ossimFileWalkerJobCallback()
virtual void started(std::shared_ptr< ossimJob > job)
std::string::size_type size() const
virtual void canceled(std::shared_ptr< ossimJob > job)
unsigned int ossim_uint32
void setNumberOfThreads(ossim_uint32 nThreads)
Sets the max number of threads(jobs) to run at one time.
~ossimFileWalker()
destructor
static ossimString downcase(const ossimString &aString)
virtual void finished(std::shared_ptr< ossimJob > job)
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
bool open(const ossimFilename &dir)
bool isDotFile(const ossimFilename &f) const
isDotFile method.
ossimFileWalker()
default constructor
virtual void started(std::shared_ptr< ossimJob > job)
std::string::size_type find_last_of(char c, std::string::size_type pos=std::string::npos) const
Equivalent to rfind(c, pos).
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
This is the base implementation for the job queue.
void setWaitOnDirFlag(bool flag)
Sets waitOnDir flag.
virtual void canceled(std::shared_ptr< ossimJob > job)
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
virtual void finished(std::shared_ptr< ossimJob > job)
void walk(const std::vector< ossimFilename > &files)
Takes an array of files.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::vector< std::string > m_filteredExtensions
This is the job callback interface It allows one to attach and listen for different states of the job...
virtual void processFile(const ossimFilename &file)=0
Pure virtual processFile method.
const std::string & string() const
void setAbortFlag(bool flag)
If set to true this stops files walking (aborts).