OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDirectoryTree.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts (gpotts@imagelinks)
6 // Description: A brief description of the contents of the file.
7 //
8 //*************************************************************************
9 // $Id: ossimDirectoryTree.cpp 9966 2006-11-29 02:01:07Z gpotts $
10 
13 #include <ossim/base/ossimRegExp.h>
15  :
16  theCurrentDirectoryData(NULL),
17  theFlags(0)
18 {
19 }
20 
22 {
23  deleteAll();
24 }
25 
26 void ossimDirectoryTree::findAllFilesThatMatch(std::vector<ossimFilename>& result,
27  const ossimString& regularExpressionPattern,
28  int flags)
29 {
30  ossimFilename filename;
31  ossimRegExp regExpr;
32  regExpr.compile(regularExpressionPattern.c_str());
33  if(getFirst(filename, flags))
34  {
35  do
36  {
37  if(regExpr.find(filename.c_str()))
38  {
39  result.push_back(filename);
40  }
41  }while(getNext(filename));
42  }
43 }
44 
46 {
48  {
49  deleteAll();
50  }
51 
55  {
56  return true;
57  }
58  else
59  {
62  }
63 
64  return isOpened();
65 }
66 
68 {
70  {
72  }
73 
74  return false;
75 }
76 
77 bool ossimDirectoryTree::getFirst(ossimFilename &filename, int flags)
78 {
79  bool result = false;
82  {
83  result = theCurrentDirectoryData->theDirectory->getFirst(filename,
84  flags);
85  while(result&&filename.isDir())
86  {
87  checkToPushDirectory(filename);
88  result = theCurrentDirectoryData->theDirectory->getNext(filename);
89  }
90 
91  if(!result)
92  {
93  if(!theDirectoryQueue.empty())
94  {
95  ossimFilename newDir = theDirectoryQueue.front();
96  theDirectoryQueue.pop();
98 
99  return getFirst(filename, flags);
100  }
101  }
102  }
103 
104  return result;
105 }
106 
107 // get next file in the enumeration started with either GetFirst() or
108 // GetFirstNormal()
110 {
111  bool result = false;
112 
114  {
115  result = theCurrentDirectoryData->theDirectory->getNext(filename);
116  if(result)
117  {
118  checkToPushDirectory(filename);
119  }
120  else
121  {
122  if(!theDirectoryQueue.empty())
123  {
124  ossimFilename newDir = theDirectoryQueue.front();
125  theDirectoryQueue.pop();
127  return getFirst(filename);
128  }
129  }
130  }
131 
132  return result;
133 }
134 
136 {
138  {
141  }
142 }
143 
145 {
146  if((filename.file().trim() == ".") ||
147  (filename.file().trim() == ".."))
148  {
149  return;
150  }
151  else if(filename.isDir())
152  {
153  theDirectoryQueue.push(filename);
154  }
155 }
void checkToPushDirectory(const ossimFilename &filename)
bool getFirst(ossimFilename &filename, int flags=OSSIM_DIR_DEFAULT)
void findAllFilesThatMatch(std::vector< ossimFilename > &result, const ossimString &regularExpressionPattern, int flags=ossimDirectory::OSSIM_DIR_DEFAULT)
bool isDir() const
bool getNext(ossimFilename &filename) const
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
bool getNext(ossimFilename &filename)
void compile(const char *)
bool open(const ossimFilename &dir)
bool open(const ossimFilename &dir)
bool isOpened() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimFilename file() const
ossimDirData * theCurrentDirectoryData
bool find(const char *)
bool getFirst(ossimFilename &filename, int flags=ossimDirectory::OSSIM_DIR_DEFAULT)
queue< ossimFilename > theDirectoryQueue