OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
ossimFilename Class Reference

#include <ossimFilename.h>

Inheritance diagram for ossimFilename:
ossimString ossimTempFilename

Public Types

enum  AccessModes {
  OSSIM_READ_WRITE = 6, OSSIM_READ = 4, OSSIM_WRITE = 2, OSSIM_EXE = 1,
  OSSIM_EXIST = 0
}
 
- Public Types inherited from ossimString
typedef std::string::const_iterator const_iterator
 
typedef std::string::iterator iterator
 
typedef std::string::size_type size_type
 

Public Member Functions

 ossimFilename ()
 
 ossimFilename (const ossimFilename &src)
 
 ossimFilename (const ossimString &src)
 
 ossimFilename (const std::string &src)
 
 ossimFilename (const char *src)
 
const ossimFilenameoperator= (const ossimFilename &f)
 
template<class Iter >
 ossimFilename (Iter s, Iter e)
 
bool operator== (const ossimFilename &rhs) const
 
bool operator== (const ossimString &rhs) const
 
bool operator== (const char *rhs) const
 
bool setTimes (ossimLocalTm *accessTime, ossimLocalTm *modTime, ossimLocalTm *createTime) const
 Writes f to the output stream os. More...
 
bool getTimes (ossimLocalTm *accessTime, ossimLocalTm *modTime, ossimLocalTm *createTime) const
 
ossim_int64 lastAccessed () const
 Time in seconds since last accessed. More...
 
bool touch () const
 
ossimFilename expand () const
 Method to do file name expansion. More...
 
bool exists () const
 
bool isFile () const
 
bool isDir () const
 
bool isReadable () const
 
bool isUrl () const
 
bool isWriteable () const
 
bool isExecutable () const
 
ossim_int64 fileSize () const
 
ossimString ext () const
 
ossimFilename path () const
 
ossimFilename drive () const
 
ossimFilename file () const
 
ossimFilename fileNoExtension () const
 
ossimFilename noExtension () const
 
ossimFilenamesetExtension (const ossimString &e)
 Sets the extension of a file name. More...
 
ossimFilenamesetDrive (const ossimString &d)
 Sets the file path and drive. More...
 
ossimFilenamesetPath (const ossimString &p)
 
ossimFilenamesetFile (const ossimString &f)
 
void split (ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
 
void merge (const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)
 
ossimFilename dirCat (const ossimFilename &file) const
 
bool createDirectory (bool recurseFlag=true, int perm=0775) const
 
bool rename (const ossimFilename &destFile, bool overwriteDestinationFlag=true) const
 
bool remove () const
 
bool wildcardRemove () const
 
bool copyFileTo (const ossimFilename &outputFile) const
 Copies this file to output file. More...
 
bool isRelative () const
 Checks whether file name is relative or absolute. More...
 
bool needsExpansion () const
 Method to check if expansion is needed. More...
 
char getPathSeparator () const
 
ossimFilenameappendTimestamp ()
 Convenience method to append a generic timestamp to the base-name portion of the filename. More...
 
ossimFilenameappend (const ossimString &append_this_to_filename)
 Convenience method to append a string to the base-name portion of the filename. More...
 
std::string native () const
 
- Public Member Functions inherited from ossimString
 ossimString ()
 default constructor More...
 
 ossimString (const std::string &s)
 constructor that takes a std::string More...
 
 ossimString (const char *aString)
 constructor that takes char* NOTE: std::string construtor throws exception given null pointer; hence, the null check. More...
 
 ossimString (const ossimString &aString)
 copy constructor More...
 
 ossimString (std::string::size_type n, char c)
 constructor - constructs with n copies of c More...
 
 ossimString (char aChar)
 constructor - constructs with 1 c. More...
 
template<class Iter >
 ossimString (Iter startIter, Iter endIter)
 
 ~ossimString ()
 destructor More...
 
bool contains (char aChar) const
 
bool contains (const ossimString &aString) const
 
bool contains (const char *aString) const
 
 operator const std::string & () const
 Type conversion operator to a const std::string&. More...
 
 operator std::string & ()
 Type conversion operator to a std::string&. More...
 
 operator const char * () const
 Type conversion operator to a const char*. More...
 
const char * chars () const
 For backward compatibility. More...
 
 operator bool () const
 
const ossimStringoperator= (const std::string &s)
 
const ossimStringoperator= (const char *s)
 
const ossimStringoperator= (char c)
 
const ossimStringoperator= (const ossimString &s)
 
const ossimStringoperator+= (const ossimString &s)
 
const ossimStringoperator+= (const std::string &s)
 
const ossimStringoperator+= (const char *s)
 
const ossimStringoperator+= (char c)
 
const ossimStringappend (const ossimString &s)
 
const ossimStringappend (const std::string &s)
 
const ossimStringappend (const char *s)
 
const char & at (std::string::size_type n) const
 Provides access to the data contained in the string. More...
 
char & at (std::string::size_type n)
 Provides access to the data contained in the string. More...
 
const ossimStringappend (std::string::size_type n, char c)
 Append n copies of c to *this. More...
 
ossimString operator+ (const ossimString &s) const
 
ossimString operator+ (const std::string &s) const
 
ossimString operator+ (const char *s) const
 
ossimString operator+ (char c) const
 
bool operator== (const ossimString &rhs) const
 Test if this ossimString is equal to another ossimString. More...
 
bool operator== (const char *rhs) const
 Test if this ossimString is equal to a C sting. More...
 
bool operator!= (const ossimString &rhs) const
 Test if this ossimString is not equal to another ossimString. More...
 
bool operator!= (const char *rhs) const
 Test if this ossimString is not equal to a C sting. More...
 
bool operator< (const ossimString &rhs) const
 
bool operator<= (const ossimString &rhs) const
 
bool operator> (const ossimString &rhs) const
 
bool operator>= (const ossimString &rhs) const
 
char & operator[] (std::string::size_type i)
 
const char & operator[] (std::string::size_type i) const
 
std::string & insert (std::string::size_type pos, const char *s)
 If pos > size(), throws out_of_range. More...
 
void push_back (char c)
 Equivalent to insert(end(), c). More...
 
std::string substr (std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
 Equivalent to basic_string(*this, pos, n). More...
 
ossimString trim (const ossimString &valueToTrim=ossimString(" \\)) const
 this will strip lead and trailing character passed in. More...
 
ossimStringtrim (const ossimString &valueToTrim=ossimString(" \\))
 
ossimString beforePos (std::string::size_type pos) const
 
ossimString afterPos (std::string::size_type pos) const
 
ossimString substitute (const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
 Substitutes searchKey string with replacementValue and returns a string. More...
 
ossimStringgsub (const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
 Substitutes searchKey string with replacementValue and returns a reference to *this. More...
 
std::vector< ossimStringexplode (const ossimString &delimeter) const
 
ossimString expandEnvironmentVariable () const
 If the variable "$(env_var_name)" is found in the string, where "env_var_name" is any system environment variable resolvable by the getenv() function, the variable is expanded in place and the result returned. More...
 
ossimStringupcase ()
 Upcases this string. More...
 
ossimString upcase () const
 
ossimStringdowncase ()
 Downcases this string. More...
 
ossimString downcase () const
 
const char * c_str () const
 Returns a pointer to a null-terminated array of characters representing the string's contents. More...
 
const char * data () const
 Returns a pointer to an array of characters (not necessarily null-terminated) representing the string's contents. More...
 
std::string::size_type size () const
 
std::string::size_type length () const
 
bool empty () const
 
const std::string & string () const
 
std::string & string ()
 
std::string::iterator begin ()
 
std::string::iterator end ()
 
std::string::const_iterator begin () const
 
std::string::const_iterator end () const
 
void clear ()
 Erases the entire container. More...
 
std::string::iterator erase (std::string::iterator p)
 Erases the character at position p. More...
 
std::string::iterator erase (std::string::iterator first, std::string::iterator last)
 Erases the range [first, last). More...
 
std::string & erase (std::string::size_type pos=0, std::string::size_type n=std::string::npos)
 Erases a range. More...
 
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. More...
 
std::string::size_type find (const char *s, std::string::size_type pos, std::string::size_type n) const
 Searches for the first n characters of s as a substring of *this, beginning at character pos of *this. More...
 
std::string::size_type find (const char *s, std::string::size_type pos=0) const
 Searches for a null-terminated character array as a substring of *this, beginning at character pos of *this. More...
 
std::string::size_type find (char c, std::string::size_type pos=0) const
 Searches for the character c, beginning at character position pos. More...
 
std::string::size_type rfind (const std::string &s, std::string::size_type pos=0) const
 Searches backward for s as a substring of *this, beginning at character position min(pos, size()). More...
 
std::string::size_type rfind (const char *s, std::string::size_type pos, std::string::size_type n) const
 Searches backward for the first n characters of s as a substring of *this, beginning at character position min(pos, size()). More...
 
std::string::size_type rfind (const char *s, std::string::size_type pos=0) const
 Searches backward for a null-terminated character array as a substring of *this, beginning at character min(pos, size()). More...
 
std::string::size_type rfind (char c, std::string::size_type pos=0) const
 Searches backward for the character c, beginning at character position min(pos, size(). More...
 
std::string::size_type find_first_of (char c, std::string::size_type pos=0) const
 Equivalent to find(c, pos). More...
 
std::string::size_type find_first_not_of (char c, std::string::size_type pos=0) const
 Returns the smallest character position N such that pos <= N < size(), and such that (*this)[N] does not compare equal to c. More...
 
std::string::size_type find_first_of (const char *s, std::string::size_type pos=0) const
 Equivalent to find_first_of(s, pos, traits::length(s)). More...
 
std::string::size_type find_first_not_of (const char *s, std::string::size_type pos=0) const
 
Equivalent to find_first_not_of(s, pos, traits::length(s)). More...
 
std::string::size_type find_last_of (char c, std::string::size_type pos=std::string::npos) const
 Equivalent to rfind(c, pos). More...
 
std::string & assign (std::string::size_type n, char c)
 Erases the existing characters and replaces them by n copies of c. More...
 
std::string & replace (std::string::size_type pos, std::string::size_type n, const std::string &s)
 Replaces a substring of *this with the string s. More...
 
std::string & replace (std::string::iterator first, std::string::iterator last, const std::string &s)
 brief Equivalent to insert(erase(first, last), s.begin(), s.end()). More...
 
std::string & replace (std::string::size_type pos, std::string::size_type n, const std::string &s, std::string::size_type pos1, std::string::size_type n1)
 Replaces a substring of *this with a substring of s. More...
 
void reserve (std::string::size_type n)
 Requests that the string's capacity be changed. More...
 
ossimString before (const ossimString &str, std::string::size_type pos=0) const
 METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If string not found or pos out of range the whole string will be returned. More...
 
ossimString after (const ossimString &str, std::string::size_type pos=0) const
 METHOD: after(str, pos) Returns string immediately after the token str. More...
 
char * stringDup () const
 
bool toBool () const
 String to numeric methods. More...
 
ossim_uint8 toUInt8 () const
 
int toInt () const
 
ossim_int16 toInt16 () const
 
ossim_uint16 toUInt16 () const
 
ossim_int32 toInt32 () const
 
ossim_uint32 toUInt32 () const
 
ossim_int64 toInt64 () const
 
ossim_uint64 toUInt64 () const
 
ossim_int64 memoryUnitToInt64 () const
 This takes a string and will test for numeric followed by a unit type: More...
 
long toLong () const
 toLong's deprecated, please use the toInts... More...
 
unsigned long toULong () const
 
ossim_float32 toFloat32 () const
 
ossim_float64 toFloat64 () const
 
double toDouble () const
 
void split (std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
 Splits this string into a vector of strings (fields) using the delimiter list specified. More...
 
std::vector< ossimStringsplit (const ossimString &separatorList, bool skipBlankFields=false) const
 
const ossimStringjoin (const std::vector< ossimString > &stringList, const ossimString &separator)
 
ossimString beforeRegExp (const char *regularExpressionPattern) const
 Returns from start of string up to but not including found pattern. More...
 
ossimString fromRegExp (const char *regularExpressionPattern) const
 Returns from position of found pattern to end of string. More...
 
ossimString afterRegExp (const char *regularExpressionPattern) const
 Returns from position after found pattern to end of string. More...
 
ossimString match (const char *regularExpressionPattern) const
 Returns from found pattern to end of pattern. More...
 
ossimString replaceAllThatMatch (const char *regularExpressionPattern, const char *value="") const
 
ossimString replaceStrThatMatch (const char *regularExpressionPattern, const char *value="") const
 
ossimString urlEncode () const
 
ossimString getOssimId () const
 If OSSIM_ID_ENABLED returns the OSSIM_ID which currently is the expanded cvs. More...
 

Static Public Member Functions

static bool remove (const ossimFilename &pathname)
 Removes pathname from filesystem if supported by platform. More...
 
static bool wildcardRemove (const ossimFilename &pathname)
 Will use a wildcard remove. More...
 
- Static Public Member Functions inherited from ossimString
static ossimString upcase (const ossimString &aString)
 
static ossimString downcase (const ossimString &aString)
 
static bool toBool (const ossimString &aString)
 
static ossim_uint8 toUInt8 (const ossimString &aString)
 
static int toInt (const ossimString &aString)
 
static ossim_int16 toInt16 (const ossimString &aString)
 
static ossim_uint16 toUInt16 (const ossimString &aString)
 
static ossim_int32 toInt32 (const ossimString &aString)
 
static ossim_uint32 toUInt32 (const ossimString &aString)
 
static ossim_int64 toInt64 (const ossimString &aString)
 
static ossim_uint64 toUInt64 (const ossimString &aString)
 
static ossim_int64 memoryUnitToInt64 (const ossimString &aString)
 
static long toLong (const ossimString &aString)
 
static unsigned long toULong (const ossimString &aString)
 
static ossim_float32 toFloat32 (const ossimString &aString)
 
static ossim_float64 toFloat64 (const ossimString &aString)
 
static double toDouble (const ossimString &aString)
 
static ossimString toString (bool aValue)
 Numeric to string methods. More...
 
static ossimString toString (ossim_int16 aValue)
 
static ossimString toString (ossim_uint16 aValue)
 
static ossimString toString (ossim_int32 aValue)
 
static ossimString toString (ossim_uint32 aValue)
 
static ossimString toString (ossim_int64 aValue)
 
static ossimString toString (ossim_uint64 aValue)
 
static ossimString toString (ossim_float32 aValue, ossim_int32 precision=8, bool fixed=false)
 
static ossimString toString (ossim_float64 aValue, ossim_int32 precision=15, bool fixed=false)
 
static ossimString stripLeading (const ossimString &value, char characterToStrip)
 

Static Public Attributes

static const ossimFilename NIL =("")
 This was taken from Wx widgets for performing touch and access date stamps. More...
 

Protected Member Functions

void converPathSeparator ()
 Converts slashes of this to internal '/' format. More...
 

Static Protected Attributes

static const char OSSIM_NATIVE_PATH_SEPARATOR = '/'
 
static const char OSSIM_FILENAME_PATH_SEPARATOR = '/'
 

Additional Inherited Members

- Protected Attributes inherited from ossimString
std::string m_str
 

Detailed Description

Definition at line 20 of file ossimFilename.h.

Member Enumeration Documentation

◆ AccessModes

Enumerator
OSSIM_READ_WRITE 
OSSIM_READ 
OSSIM_WRITE 
OSSIM_EXE 
OSSIM_EXIST 

Definition at line 23 of file ossimFilename.h.

Constructor & Destructor Documentation

◆ ossimFilename() [1/6]

ossimFilename::ossimFilename ( )

Definition at line 210 of file ossimFilename.cpp.

Referenced by createDirectory(), drive(), ext(), file(), fileNoExtension(), ossimTempFilename::generate(), merge(), path(), and wildcardRemove().

211  : ossimString()
212 {}
ossimString()
default constructor
Definition: ossimString.h:31

◆ ossimFilename() [2/6]

ossimFilename::ossimFilename ( const ossimFilename src)

Definition at line 214 of file ossimFilename.cpp.

215  : ossimString(src)
216 {
217 }
ossimString()
default constructor
Definition: ossimString.h:31

◆ ossimFilename() [3/6]

ossimFilename::ossimFilename ( const ossimString src)

Definition at line 219 of file ossimFilename.cpp.

References converPathSeparator(), and ossimString::m_str.

220  : ossimString(src)
221 {
222  if ( m_str.size() )
223  {
225  // convertToNative();
226  }
227 }
std::string m_str
Definition: ossimString.h:733
ossimString()
default constructor
Definition: ossimString.h:31
void converPathSeparator()
Converts slashes of this to internal &#39;/&#39; format.

◆ ossimFilename() [4/6]

ossimFilename::ossimFilename ( const std::string &  src)

Definition at line 229 of file ossimFilename.cpp.

References converPathSeparator(), and ossimString::m_str.

230  : ossimString(src)
231 {
232  if ( m_str.size() )
233  {
235  // convertToNative();
236  }
237 }
std::string m_str
Definition: ossimString.h:733
ossimString()
default constructor
Definition: ossimString.h:31
void converPathSeparator()
Converts slashes of this to internal &#39;/&#39; format.

◆ ossimFilename() [5/6]

ossimFilename::ossimFilename ( const char *  src)

Definition at line 239 of file ossimFilename.cpp.

References converPathSeparator(), and ossimString::m_str.

240  : ossimString(src)
241 {
242  if ( m_str.size() )
243  {
245  // convertToNative();
246  }
247 }
std::string m_str
Definition: ossimString.h:733
ossimString()
default constructor
Definition: ossimString.h:31
void converPathSeparator()
Converts slashes of this to internal &#39;/&#39; format.

◆ ossimFilename() [6/6]

template<class Iter >
ossimFilename::ossimFilename ( Iter  s,
Iter  e 
)

Definition at line 258 of file ossimFilename.cpp.

References converPathSeparator(), and ossimString::m_str.

259  : ossimString(s, e)
260 {
261  if ( m_str.size() )
262  {
264  // convertToNative();
265  }
266 }
std::string m_str
Definition: ossimString.h:733
ossimString()
default constructor
Definition: ossimString.h:31
void converPathSeparator()
Converts slashes of this to internal &#39;/&#39; format.

Member Function Documentation

◆ append()

ossimFilename & ossimFilename::append ( const ossimString append_this_to_filename)

Convenience method to append a string to the base-name portion of the filename.

Returns this.

Definition at line 1426 of file ossimFilename.cpp.

References merge(), and split().

Referenced by appendTimestamp(), and ossimTool::readTextFile().

1427 {
1428  ossimString drivePart;
1429  ossimString pathPart;
1430  ossimString filePart;
1431  ossimString extPart;
1432 
1433  split(drivePart, pathPart, filePart, extPart);
1434  filePart += append_this;
1435  merge(drivePart, pathPart, filePart, extPart);
1436 
1437  return *this;
1438 }
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ appendTimestamp()

ossimFilename & ossimFilename::appendTimestamp ( )

Convenience method to append a generic timestamp to the base-name portion of the filename.

This is useful for establishing rolling names for temporary files and logs. Returns this.

Definition at line 1417 of file ossimFilename.cpp.

References append(), and ossim::getFormattedTime().

Referenced by ossimDemTool::loadJSON().

1418 {
1419  const std::string format = "%Y%m%d-%H%Mh%Ss";
1420  std::string timestamp;
1421  ossim::getFormattedTime(format, true, timestamp);
1422 
1423  return append(timestamp);
1424 }
OSSIM_DLL void getFormattedTime(const std::string &format, bool gmtFlag, std::string &result)
Gets the current time.
ossimFilename & append(const ossimString &append_this_to_filename)
Convenience method to append a string to the base-name portion of the filename.

◆ converPathSeparator()

void ossimFilename::converPathSeparator ( )
protected

Converts slashes of this to internal '/' format.

Definition at line 1440 of file ossimFilename.cpp.

References ossimString::m_str, and OSSIM_FILENAME_PATH_SEPARATOR.

Referenced by ossimFilename().

1441 {
1442  if ( m_str.size() )
1443  {
1444  std::replace( m_str.begin(), m_str.end(), '\\', OSSIM_FILENAME_PATH_SEPARATOR );
1445  }
1446 }
std::string m_str
Definition: ossimString.h:733
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ copyFileTo()

bool ossimFilename::copyFileTo ( const ossimFilename outputFile) const

Copies this file to output file.

Copies this to output file. If output file is a directory, this->file() is appended to output file.

Parameters
outputFileFile name to copy to.
Returns
True on success, false on error.

Definition at line 1289 of file ossimFilename.cpp.

References ossimString::c_str(), dirCat(), file(), isDir(), ossimNotify(), and ossimNotifyLevel_WARN.

1290 {
1291  bool result = false;
1292 
1293  std::ifstream is(this->c_str(), std::ios::in|std::ios::binary);
1294  if ( is.good() )
1295  {
1296  ossimFilename f = outputFile;
1297  if ( f.isDir() )
1298  {
1299  f = f.dirCat( this->file() );
1300  }
1301 
1302  if ( f != *this )
1303  {
1304  std::ofstream os( f.c_str(), std::ios::out|std::ios::binary );
1305  if ( os.good() )
1306  {
1307  // Copy the file:
1308  char c;
1309  while(is.get(c))
1310  {
1311  os.put(c);
1312  }
1313 
1314  if ( is.eof() && !os.fail())
1315  {
1316  result = true;
1317  }
1318  else
1319  {
1321  << "WARNING: "
1322  << "ossimFilename::copyFileTo WARNING:"
1323  << "\nError detected writing from file "
1324  << this->c_str() << " to file " << f.c_str() << std::endl;
1325  }
1326  }
1327  else
1328  {
1330  << "WARNING: "
1331  << "ossimFilename::copyFileTo WARNING:"
1332  << "\nCannot open: " << f.c_str() << std::endl;
1333  }
1334  } // if ( f != *this )
1335  else
1336  {
1338  << "WARNING: "
1339  << "ossimFilename::copyFileTo WARNING:"
1340  << "\nFiles the same!" << std::endl;
1341  }
1342 
1343  } // if ( is.good() )
1344  else
1345  {
1347  << "WARNING: "
1348  << "ossimFilename::copyFileTo WARNING:"
1349  << "\nCannot open: " << this->c_str() << std::endl;
1350  }
1351 
1352  return result;
1353 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
bool isDir() const
ossimFilename dirCat(const ossimFilename &file) 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
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ createDirectory()

bool ossimFilename::createDirectory ( bool  recurseFlag = true,
int  perm = 0775 
) const

Definition at line 1086 of file ossimFilename.cpp.

References ossimString::c_str(), ossimString::empty(), exists(), expand(), ossimString::length(), OSSIM_FILENAME_PATH_SEPARATOR, ossimFilename(), and ossimString::split().

Referenced by ossimBatchTest::execute(), ossimTempFilename::generate(), ossimBatchTest::getTempFileName(), ossimBatchTest::makeDefaultResultsDir(), and ossimToolClient::setProductFilePath().

1088 {
1089  if(exists()) return true;
1090 
1091  if ( empty() ) return false;
1092 
1093  if(recurseFlag)
1094  {
1095  ossimString tempString = this->expand().c_str();
1096 
1097  vector<ossimString> result;
1098  tempString.split(result,OSSIM_FILENAME_PATH_SEPARATOR);
1099 
1100  if(result.size())
1101  {
1102  ossimString current = result[0];
1103 
1104 // Reconstruct UNC paths under Windows.
1105 #if defined(_WIN32)
1106  bool bGotUNC = false;
1107  if ( current.length() == 0 && tempString.length() > 2 )
1108  {
1109  const char* fstr = tempString.c_str();
1110  const char fstar0 = fstr[0];
1111  const char fstar1 = fstr[1];
1112  if ( fstar0=='\\' && fstar1=='\\' )
1113  {
1114  bGotUNC = true;
1116  }
1117  }
1118 #endif
1119 
1120  for(ossim_uint32 i = 1; i < result.size(); ++i)
1121  {
1122  current += (OSSIM_FILENAME_PATH_SEPARATOR+result[i]);
1123 
1124 #if defined(_WIN32)
1125  if ( bGotUNC == true && i==1 )
1126  {
1127  // The root of the UNC path is assumed to exist.
1128  continue;
1129  }
1130 #endif
1131 
1132  if(current != OSSIM_FILENAME_PATH_SEPARATOR)
1133  {
1134  if(!ossimFilename(current).exists())
1135  {
1136 #if defined(__BORLANDC__)
1137  if ( _mkdir(current.c_str()) != 0 )
1138 #elif defined(_WIN32)
1139  if ( _mkdir(current.c_str()) != 0 )
1140 #else
1141  if ( mkdir(current.c_str(), perm) != 0 )
1142 #endif
1143  {
1144  return false;
1145  }
1146  }
1147  }
1148  }
1149  }
1150  }
1151  else
1152  {
1153 #if defined (__BORLANDC__)
1154  if ( _mkdir(c_str()) != 0 )
1155 #elif defined(_WIN32)
1156  if ( _mkdir(c_str()) != 0 )
1157 #else
1158  if ( mkdir(c_str(), perm) != 0 )
1159 #endif
1160  {
1161  return false;
1162  }
1163  else
1164  {
1165  return true;
1166  }
1167  }
1168  return true;
1169 }
ossimFilename expand() const
Method to do file name expansion.
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
bool exists() const
std::string::size_type length() const
Definition: ossimString.h:408
unsigned int ossim_uint32
static const char OSSIM_FILENAME_PATH_SEPARATOR
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
bool empty() const
Definition: ossimString.h:411

◆ dirCat()

ossimFilename ossimFilename::dirCat ( const ossimFilename file) const

Returns file appended onto this string. Path seperator is always placed between this and file. Returns file if this string is empty. Given: this = /foo and file = bar output = /foo/bar Given: this = /foo/ and file = bar output = /foo/bar

Definition at line 1002 of file ossimFilename.cpp.

References ossimString::begin(), ossimString::empty(), ossimString::end(), file(), OSSIM_FILENAME_PATH_SEPARATOR, ossimString::ossimString(), and ossimString::size().

Referenced by ossimSingleImageChain::addHistogramRemapper(), ossimVpfAnnotationFeatureInfo::buildEdgFeature(), ossimVpfAnnotationFeatureInfo::buildFaceFeature(), ossimVpfAnnotationFeatureInfo::buildPointFeature(), ossimVpfAnnotationFeatureInfo::buildTxtFeature(), ossimNadconGridDatum::checkGrid(), copyFileTo(), ossimImageHandler::createDefaultValidVerticesFilename(), ossimSrtmElevationDatabase::createFullPath(), ossimDtedElevationDatabase::createFullPath(), ossimGeneralRasterElevationDatabase::createFullPath(), ossimplugins::ossimPluginProjectionFactory::createProjection(), ossimDtedElevationDatabase::createRelativePath(), ossimBatchTest::execute(), expand(), ossimEnvironmentUtility::findData(), ossimEnvironmentUtility::findPlugin(), ossimTempFilename::generate(), ossimIgenGenerator::generateGeoTiledSpecList(), ossimIgenGenerator::generatePixelTiledSpecList(), ossimVpfLibrary::getCoverage(), ossimBatchTest::getDefaultTempFileDir(), ossimRpfUtil::getDotRfpFilenameForEntry(), ossimVpfCoverage::getExtent(), ossimImageHandler::getExternalImageGeometry(), ossimEnvironmentUtility::getInstalledOssimPluginDir(), ossimEnvironmentUtility::getInstalledOssimPreferences(), ossimTool::getKwlTemplate(), ossimH5ImageHandler::getLatLonDatasets(), ossimRpfToc::getSourceTocFile(), ossimVpfFeatureClass::getTable1(), ossimVpfFeatureClass::getTable2(), ossimBatchTest::getTempFileName(), ossimVpfLibrary::getTileName(), ossimVpfLibrary::getTileNames(), ossimEnvironmentUtility::getUserOssimPluginDir(), ossimEnvironmentUtility::getUserOssimPreferences(), ossimEnvironmentUtility::getUserOssimSupportDir(), ossimVerticesFinderTool::initialize(), ossimEpsgProjectionDatabase::initialize(), ossimInit::initializePlugins(), ossimplugins::ossimRadarSat2Model::InitLut(), ossimWktProjectionFactory::loadRecords(), ossimElevManager::loadStandardElevationPaths(), merge(), ossimGeoidNgs::open(), ossimplugins::ossimRadarSat2TiffReader::open(), ossimplugins::ossimTerraSarTiffReader::open(), ossimplugins::ossimPleiadesModel::open(), ossimplugins::ossimSpot6Model::open(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimVpfCoverage::openCoverage(), ossimVpfFeatureClassSchema::openSchema(), ossimImageHandler::openValidVertices(), ossimNadconGridDatum::ossimNadconGridDatum(), ossimBilSplitter::output_multi_files(), ossimIgen::outputProduct(), ossimVpfCoverage::print(), ossimDirectoryData::read(), ossimAlphaSensorSupportData::readSupportFiles(), ossimToolClient::receiveFile(), ossimVpfLibrary::setCoverageNames(), ossimRpfFrameEntry::setEntry(), ossimVpfLibrary::setTileNames(), ossimSpot5Model::setupOptimizer(), and ossimplugins::ossimFormosatModel::setupOptimizer().

1003 {
1004  // If this string is empty simply return the input file.
1005  if (empty()) return file;
1006  if (file.empty()) return *this;
1007 
1008  ossimFilename dir = *this;
1009  ossimFilename tempFile = file;
1010 
1011  // Check the end and see if it already has a "/".
1012  string::const_iterator i = dir.end();
1013 
1014  --i; // decrement past the trailing null.
1015 
1016  if ( (*i) != OSSIM_FILENAME_PATH_SEPARATOR)
1017  {
1019  }
1020 
1021  // check for dot slash or just slash: ./foo or /foo
1022  std::string::iterator iter = tempFile.begin();
1023  if (iter != tempFile.end())
1024  {
1025  if ((*iter) == OSSIM_FILENAME_PATH_SEPARATOR)
1026  {
1027  ++iter; // skip slash
1028  }
1029  else if (tempFile.size() > 1)
1030  {
1031  if ( ((*iter) == '.') && ( *(iter + 1) == OSSIM_FILENAME_PATH_SEPARATOR) )
1032  {
1033  iter = iter + 2; // skip dot slash
1034  }
1035  }
1036  }
1037 
1038  dir += std::string(iter, tempFile.end());
1039 
1040  return dir;
1041 }
std::string::iterator end()
Definition: ossimString.h:423
ossimString()
default constructor
Definition: ossimString.h:31
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420
static const char OSSIM_FILENAME_PATH_SEPARATOR
bool empty() const
Definition: ossimString.h:411
ossimFilename file() const

◆ drive()

ossimFilename ossimFilename::drive ( ) const
Returns
"c:" if file is "c:\data\images\t1.tif".

Definition at line 804 of file ossimFilename.cpp.

References ossimString::begin(), ossimRegExp::end(), ossimRegExp::find(), ossimString::m_str, ossimFilename(), ossimString::ossimString(), and ossimRegExp::start().

Referenced by ossimImageHandler::getFilenameWithNoExtension(), and split().

805 {
806  ossimFilename result;
807  ossimRegExp regEx("^([a-z|A-Z])+:");
808  if(regEx.find( m_str.c_str() ) )
809  {
810  result = ossimFilename(ossimString(this->begin() + regEx.start(),
811  this->begin() + regEx.end()));
812  }
813  else
814  {
815  result = "";
816  }
817 
818  return result;
819 }
std::string m_str
Definition: ossimString.h:733
ossimString()
default constructor
Definition: ossimString.h:31
std::string::iterator begin()
Definition: ossimString.h:420

◆ exists()

bool ossimFilename::exists ( ) const

Definition at line 650 of file ossimFilename.cpp.

References ossimString::c_str(), ossim::StreamFactoryRegistry::exists(), ossim::StreamFactoryRegistry::instance(), isUrl(), and OSSIM_EXIST.

Referenced by ossimGeoidNgs::addFile(), ossimHistogramMatchFilter::autoLoadInputHistogram(), ossimVpfAnnotationFeatureInfo::buildEdgFeature(), ossimVpfAnnotationFeatureInfo::buildFaceFeature(), ossimVpfAnnotationFeatureInfo::buildPointFeature(), ossimVpfAnnotationFeatureInfo::buildTxtFeature(), ossimSrtmElevationDatabase::createCell(), ossimDtedElevationDatabase::createCell(), createDirectory(), ossim::StreamFactory::createIstream(), ossimSensorModelFactory::createProjection(), ossimplugins::ossimPluginProjectionFactory::createProjection(), ossimMapProjectionFactory::createProjection(), ossimBatchTest::doDefaultClean(), ossimBatchTest::execute(), ossimplugins::ossimAlosPalsarModel::findAlosPalsarData(), ossimplugins::ossimAlosPalsarModel::findAlosPalsarLeader(), ossimSensorModelFactory::findCoarseGrid(), ossimEnvironmentUtility::findData(), ossimplugins::ossimErsSarModel::findErsLeader(), ossimLandsatTopoCorrectionFilter::findLandsatHeader(), ossimEnvironmentUtility::findPlugin(), ossimQuickbirdRpcModel::findSupportFile(), ossimplugins::ossimTerraSarModel::findTSXLeader(), ossimTempFilename::generate(), ossimVpfCoverage::getExtent(), ossimMrSidReader::getExternalImageGeometry(), ossimImageHandler::getExternalImageGeometry(), ossimGdalTileSource::getExternalImageGeometryFromXml(), ossimMrSidReader::getGeoProjection(), ossimQbTileFilesHandler::getImageGeometry(), ossimGeneralRasterTileSource::getImageGeometry(), ossimEnvironmentUtility::getInstalledOssimPluginDir(), ossimEnvironmentUtility::getInstalledOssimPreferences(), ossimEnvironmentUtility::getInstalledOssimSupportDir(), ossimH5ImageHandler::getLatLonDatasets(), ossimRpfToc::getSourceTocFile(), ossimVpfLibrary::getTileName(), ossimVpfLibrary::getTileNames(), getTimes(), ossimMultiBandHistogram::importHistogram(), ossimHistogram::importHistogram(), ossimLasReader::init(), ossimInit::initializePlugins(), ossimplugins::ossimRadarSat2Model::InitLut(), ossimAuxFileHandler::isAuxFile(), ossimCcfTileSource::isEcgGeom(), ossimArcInfoGridWriter::isOpen(), ossimDemUtil::isUsgsDem(), lastAccessed(), ossimGdalOgrVectorAnnotation::loadExternalGeometryFile(), ossimGdalOgrVectorAnnotation::loadExternalImageGeometryFromXml(), ossimDtedTileSource::loadMetaData(), ossimGdalOgrVectorAnnotation::loadOmdFile(), ossimInit::loadPlugins(), ossimElevManager::loadStandardElevationPaths(), ossimSrtmElevationDatabase::loadState(), ossimDtedElevationDatabase::loadState(), ossimGeneralRasterElevationDatabase::loadState(), ossimRgbLutDataObject::loadState(), ossimNBandLutDataObject::loadState(), ossimBatchTest::makeDefaultResultsDir(), ossimPointCloudImageHandlerFactory::open(), ossimGeoidNgs::open(), ossimArcInfoGridWriter::open(), ossimERSTileSource::open(), ossimEnviInfo::open(), ossimKakaduJpipHandler::open(), ossimplugins::ossimPleiadesModel::open(), ossimplugins::ossimSpot6Model::open(), ossimplugins::ossimErsSarModel::open(), ossimplugins::ossimRadarSatModel::open(), ossimplugins::ossimAlosPalsarModel::open(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimGpkgWriter::open(), ossimVpfCoverage::openCoverage(), ossimVpfDatabase::openDatabase(), ossimGeneralRasterElevationDatabase::openGeneralRasterDirectory(), ossimVpfFeatureClassSchema::openSchema(), ossimAdrgHeader::ossimAdrgHeader(), ossimNitfRsmModel::parseFile(), ossimSrtmElevationDatabase::pointHasCoverage(), ossimDtedElevationDatabase::pointHasCoverage(), ossimCibCadrgTileSource::populateLut(), ossimGdalWriter::postProcessOutput(), ossimAlphaSensorSupportData::readSupportFiles(), rename(), ossimGeneralRasterElevFactory::setDirectory(), ossimRpfFrameEntry::setEntry(), ossimMapViewController::setFilename(), ossimGeneralRasterElevHandler::setFilename(), ossimBandLutFilter::setLut(), ossimIndexToRgbLutFilter::setLut(), ossimToolClient::setProductFilePath(), ossimSpot5Model::setupOptimizer(), ossimplugins::ossimFormosatModel::setupOptimizer(), ossimCibCadrgTileSource::updatePropertiesToFirstValidFrame(), ossimBatchTest::writeTemplate(), and ossimImageHandler::writeValidImageVertices().

651 {
652  bool result = false;
653  if ( isUrl() == false )
654  {
655 #if defined(_WIN32)
656  result = (_access(c_str(), ossimFilename::OSSIM_EXIST) == 0);
657 #else
658  result = ((access(c_str(), ossimFilename::OSSIM_EXIST)) == 0);
659 #endif
660  }
661  else
662  {
663  result = ossim::StreamFactoryRegistry::instance()->exists( this->string() );
664  }
665  return result;
666 }
static StreamFactoryRegistry * instance()
bool exists(const std::string &connectionString) const
Methods to test if connection exists.
bool isUrl() 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

◆ expand()

ossimFilename ossimFilename::expand ( ) const

Method to do file name expansion.

Like: ~/docs will be expanded to /home/user/docs

Returns
The expanded file name.
Note
METHOD IS NOT COMPLETE YET.

Definition at line 494 of file ossimFilename.cpp.

References ossimString::begin(), ossimString::c_str(), dirCat(), ossimString::end(), ossimEnvironmentUtility::getUserDir(), ossimString::gsub(), ossimEnvironmentUtility::instance(), isRelative(), needsExpansion(), OSSIM_FILENAME_PATH_SEPARATOR, ossimString::ossimString(), and ossimString::size().

Referenced by createDirectory(), ossimImageHandler::getExternalImageGeometry(), ossimRpfToc::getRootDirectory(), ossimBatchTest::getTempFileName(), getTimes(), ossimplugins::ossimRadarSat2Model::InitLut(), lastAccessed(), ossim::Image::loadJSON(), ossimplugins::ossimRadarSat2TiffReader::open(), ossimplugins::ossimTerraSarTiffReader::open(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimTerraSarModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimBatchTest::processConfigList(), ossimAlphaSensorSupportData::readSupportFiles(), ossimInfo::testPlugin(), and touch().

495 {
496  //---
497  // Note: ossimEnvironmentUtility::getCurrentWorkingDir() is returning
498  // a blank string on windows with vs9. This was resulting in seg faults
499  // in this method so added checks were added for size of returned result.
500  // (drb 20100113)
501  //---
502  ossimFilename result = "";
503  if ( size() )
504  {
505  result = *this;
506 
507  if ( needsExpansion() )
508  {
509 
510 //#if defined(_WIN32)
511 // result.convertBackToForwardSlashes();
512 //#endif
513 
514  bool addCwd = false;
515 
516  if ( (size() > 1) && (*(begin()) == '~') && (*(begin()+1) == OSSIM_FILENAME_PATH_SEPARATOR) )
517  {
518  ossimFilename homeDir =
520 
521  ossimFilename s( (result.begin()+2) , result.end());
522  result = homeDir.dirCat(s);
523  }
524  else if( (size() > 1) &&
525  (*(begin()) == '.') && (*(begin()+1) == OSSIM_FILENAME_PATH_SEPARATOR) )
526  {
527  // dot slash i.e. ./foo
528  addCwd = true;
529  }
530  else if ( (size() > 2) && (*(begin()) == '.')
531  && (*(begin()+1) == '.') && (*(begin()+2) == OSSIM_FILENAME_PATH_SEPARATOR) )
532  {
533  // ../foo
534  addCwd = true;
535  }
536  else if (result == ".")
537  {
539  getCurrentWorkingDir();
540  }
541 
542  if (addCwd)
543  {
545  getCurrentWorkingDir();
546  result = cwd.dirCat(result);
547  }
548  else if ( result.isRelative() )
549  {
550  if ( result.size() && ((*(result.begin())) != '$') )
551  {
553  getCurrentWorkingDir();
554  result = cwd.dirCat(result);
555  }
556  }
557 
558  // Check result to see if we're finished.
559  if ( result.needsExpansion() )
560  {
561  // now expand any environment variable substitutions
562 
563  ossimFilename finalResult;
564  const char* tempPtr = result.c_str();
565  ossim_int32 startIdx = -1;
566  ossim_int32 resultSize = (ossim_uint32)result.size();
567  ossim_int32 scanIdx = 0;
568  while(scanIdx < resultSize)
569  {
570  // look for start of substitution pattern
571  if(tempPtr[scanIdx] == '$')
572  {
573  if(tempPtr[scanIdx+1] == '(')
574  {
575  scanIdx += 2;
576  startIdx = scanIdx;
577  }
578  else
579  {
580  //---
581  // Infinite loop fix with below file on window:
582  // "\\kiosk\x$\SourceImagery\foo.ntf" (drb 21 Nov. 2016)
583  //---
584  finalResult += tempPtr[scanIdx];
585  ++scanIdx;
586  }
587  }
588  // look for an end pattern and apply if we found a start pattern
589  else if(tempPtr[scanIdx] == ')')
590  {
591  if(startIdx != -1)
592  {
593  ossimFilename value(
595  getEnvironmentVariable(ossimString(tempPtr+startIdx,
596  tempPtr+scanIdx)));
597 #if defined(_WIN32) // do windows style replacment
598  // value.convertBackToForwardSlashes();
599 #endif
600  finalResult += value;
601  // reset start idx indicator to not set so we are ready for next pattern
602  //
603  startIdx = -1;
604  }
605  else // if no start then tack on the )
606  {
607  finalResult += tempPtr[scanIdx];
608  }
609  ++scanIdx;
610  }
611  else if(startIdx == -1)
612  {
613  finalResult += tempPtr[scanIdx];
614  ++scanIdx;
615  }
616  else
617  {
618  ++scanIdx;
619  }
620  }
621 #if defined(_WIN32)
622 
623 #else
624  finalResult.gsub("//", "/", true);
625 #endif
626  result = finalResult;
627 
628  } // matches: if ( result.needsExpansion() )
629 
630 #if defined(_WIN32)
631  // result.convertForwardToBackSlashes();
632 #endif
633 
634  } // matches: if ( needsExpansion() )
635 
636  //---
637  // If we had a size before "expand()" and now we don't something went
638  // wrong...
639  //---
640  if (!result.size())
641  {
642  result = *this;
643  }
644 
645  } // matches: if ( size() )
646 
647  return result;
648 }
std::string::iterator end()
Definition: ossimString.h:423
ossimString()
default constructor
Definition: ossimString.h:31
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420
unsigned int ossim_uint32
static const char OSSIM_FILENAME_PATH_SEPARATOR
static ossimEnvironmentUtility * instance()
ossimFilename dirCat(const ossimFilename &file) 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
bool needsExpansion() const
Method to check if expansion is needed.
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
ossimFilename getUserDir() const
int ossim_int32

◆ ext()

ossimString ossimFilename::ext ( ) const
Returns
"tif" if file is "/data/images/t1.tif".
Note
The '.' (dot) is not returned.

Definition at line 768 of file ossimFilename.cpp.

References ossimString::m_str, NIL, and ossimFilename().

Referenced by ossimSqliteInfoFactory::create(), ossimJpipProjectionFactory::createProjection(), ossimImageWriterFactoryRegistry::createWriter(), ossimShorelineTool::execute(), ossimQuickbirdRpcModel::findSupportFile(), ossimplugins::ossimTerraSarModel::findTSXLeader(), ossimIgenGenerator::generateGeoTiledSpecList(), ossimIgenGenerator::generatePixelTiledSpecList(), ossimBandSeparateHandler::getBandFileNames(), ossimKmlSuperOverlayWriter::getExtension(), ossimGeneralRasterTileSource::getImageGeometry(), ossimKmlSuperOverlayReaderFactory::hasExcludedExtension(), ossimH5ReaderFactory::hasExcludedExtension(), ossimMrSidReaderFactory::hasExcludedExtension(), ossimGeoPdfReaderFactory::hasExcludedExtension(), ossimJpeg12ReaderFactory::hasExcludedExtension(), ossimOpjReaderFactory::hasExcludedExtension(), ossimKakaduReaderFactory::hasExcludedExtension(), ossimDtedElevationDatabase::inititializeExtension(), ossimAuxFileHandler::isAuxFile(), ossimChipperUtil::isDemFile(), ossimFileWalker::isFiltered(), ossimOgrVectorTileSource::isOgrVectorDataSource(), ossimRpfInfo::isOpen(), ossimGeoPdfInfo::isOpen(), ossimGeoPdfReader::isOpen(), ossimRpfCacheTileSource::isOpen(), ossimplugins::ossimRadarSat2TiffReader::isRadarSat2ProductFile(), ossimAutRegUtil::isSrcFile(), ossimChipperUtil::isSrcFile(), ossimBitMaskTileSource::isSupportedExtension(), ossimHdfReader::isSupportedExtension(), ossimplugins::ossimTerraSarTiffReader::isTerraSarProductFile(), ossimplugins::ossimPluginProjectionFactory::isTileMap(), ossimDemUtil::isUsgsDem(), ossimPointCloudImageHandlerFactory::open(), ossimEnviInfo::open(), ossimGdalFactory::open(), ossimKakaduJpipHandler::open(), ossimHdf5PluginHandlerFactory::open(), ossimplugins::ossimRadarSat2TiffReader::open(), ossimCcfInfo::open(), ossimKakaduJpipInfo::open(), ossimKmlSuperOverlayReader::open(), ossimplugins::ossimTerraSarTiffReader::open(), ossimDtedInfo::open(), ossimplugins::ossimPleiadesModel::open(), ossimplugins::ossimSpot6Model::open(), ossimplugins::ossimTileMapModel::open(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimImageHandlerRegistry::openBySuffix(), ossimGeneralRasterElevationDatabase::openGeneralRasterDirectory(), ossimInfo::openImage(), ossimInfo::openImageHandler(), ossimAdrgHeader::ossimAdrgHeader(), ossimXmpInfo::print(), ossimGeneralRasterElevFactory::setDirectory(), split(), and ossimImageFileWriter::writeWorldFile().

769 {
770  std::string::size_type pos = m_str.rfind('.');
771  if (pos == std::string::npos)
772  {
773  return ossimFilename::NIL;
774  }
775 
776  return ossimFilename(m_str.substr(pos+1));
777 }
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
std::string m_str
Definition: ossimString.h:733

◆ file()

ossimFilename ossimFilename::file ( ) const
Returns
"t1.tif" if file is "/data/images/t1.tif".

Definition at line 779 of file ossimFilename.cpp.

References ossimString::m_str, OSSIM_FILENAME_PATH_SEPARATOR, and ossimFilename().

Referenced by ossimDirectoryTree::checkToPushDirectory(), copyFileTo(), ossimplugins::ossimPluginProjectionFactory::createProjection(), dirCat(), ossimDirectory::findAllFilesThatMatch(), ossimplugins::ossimTerraSarModel::findTSXLeader(), ossimGdalOverviewBuilder::generateHfaStats(), ossimRpfToc::getCorespondingEntry(), ossimImageHandler::getExternalImageGeometry(), ossimQuickbirdTiffTileSource::getImageGeometry(), ossimSharedPluginRegistry::getPlugin(), ossimplugins::ossimTerraSarModel::getPolLayerFromImageFile(), ossimPdfWriter::getTitle(), ossimDtedElevationDatabase::inititializeExtension(), ossimImageUtil::isFiltered(), ossimSharedPluginRegistry::isLoaded(), ossimTiffWorld::open(), ossimplugins::ossimSpot6Model::open(), ossimplugins::ossimPleiadesModel::open(), ossimQuickbirdRpcModel::parseTileData(), ossimAlphaSensorSupportData::readHdrFile(), ossimAlphaSensorSupportData::readSupportFiles(), ossimToolServer::sendFile(), ossimImageUtil::substituteFileStrings(), and wildcardRemove().

780 {
781  std::string::size_type pos = m_str.rfind(OSSIM_FILENAME_PATH_SEPARATOR);
782  if (pos == std::string::npos)
783  return *this;
784  else
785  return ossimFilename(m_str.substr(pos+1));
786 }
std::string m_str
Definition: ossimString.h:733
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ fileNoExtension()

ossimFilename ossimFilename::fileNoExtension ( ) const
Returns
"t1" if file is "/data/images/t1.tif".

Definition at line 821 of file ossimFilename.cpp.

References ossimString::begin(), ossimString::end(), ossimString::m_str, OSSIM_FILENAME_PATH_SEPARATOR, and ossimFilename().

Referenced by ossimSingleImageChain::addHistogramRemapper(), ossimImageHandler::createDefaultValidVerticesFilename(), ossimBatchTest::execute(), ossimplugins::ossimAlosPalsarModel::findAlosPalsarData(), ossimplugins::ossimAlosPalsarModel::findAlosPalsarLeader(), ossimSensorModelFactory::findCoarseGrid(), ossimplugins::ossimErsSarModel::findErsLeader(), ossimIgenGenerator::generateGeoTiledSpecList(), ossimIgenGenerator::generatePixelTiledSpecList(), ossimKmlSuperOverlayWriter::generateRootKml(), ossimVerticesFinderTool::initialize(), ossimDtedTileSource::loadMetaData(), ossimERSTileSource::open(), ossimIkonosMetaData::open(), ossimImageHandler::openValidVertices(), ossimAdrgHeader::parse(), ossimQuickbirdRpcModel::parseRpcData(), ossimBatchTest::processTest(), ossimSrtmFilename::setFilename(), split(), and ossimKakaduJp2Writer::writeGeotiffBox().

822 {
823  std::string::size_type dot_pos = m_str.rfind('.');
824  std::string::size_type slash_pos = m_str.rfind(OSSIM_FILENAME_PATH_SEPARATOR);
825 
826  if(dot_pos == std::string::npos)
827  {
828  if(slash_pos == std::string::npos)
829  {
830  return *this;
831  }
832  else
833  {
834  return ossimFilename(this->begin()+slash_pos+1,
835  this->end());
836  }
837  }
838  else if(slash_pos == std::string::npos)
839  {
840  return ossimFilename(this->begin(), this->begin()+dot_pos);
841  }
842  else if(slash_pos < dot_pos)
843  {
844  return ossimFilename(this->begin()+slash_pos+1,
845  this->begin() + dot_pos);
846  }
847 
848  return ossimFilename(this->begin()+slash_pos+1,
849  this->end());
850 
851 }
std::string m_str
Definition: ossimString.h:733
std::string::iterator end()
Definition: ossimString.h:423
std::string::iterator begin()
Definition: ossimString.h:420
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ fileSize()

ossim_int64 ossimFilename::fileSize ( ) const

Definition at line 1043 of file ossimFilename.cpp.

References ossimString::c_str(), ossimFileInfoInterface::getFileSize(), ossim::StreamFactoryRegistry::instance(), isUrl(), and ossimString::size().

Referenced by ossimGeneralRasterTileSource::getXmlInfo(), ossimGeneralRasterInfo::initializeFromXml(), ossimSrtmHandler::open(), ossimGeneralRasterElevHandler::open(), ossimBilSplitter::ossimBilSplitter(), ossimplugins::ossimSpot6DimapSupportData::parseXmlFile(), ossimplugins::ossimPleiadesDimapSupportData::parseXmlFile(), and ossimGeoTiff::writeJp2GeotiffBox().

1044 {
1045  ossim_int64 size = 0;
1046 
1047  if ( isUrl() == false )
1048  {
1049  struct stat sbuf;
1050  if ( stat( this->c_str(), &sbuf ) == 0 )
1051  {
1052  size = (ossim_int64)sbuf.st_size;
1053  }
1054  else
1055  {
1056  ifstream in(c_str());
1057  if(in)
1058  {
1059  in.seekg(0, std::ios_base::end);
1060  size = (ossim_int64)in.tellg();
1061  }
1062  }
1063  }
1064  else
1065  {
1066  std::shared_ptr<ossim::istream> in = ossim::StreamFactoryRegistry::instance()->
1067  createIstream( this->string() );
1068  if ( in )
1069  {
1070  ossimFileInfoInterface* intf = dynamic_cast<ossimFileInfoInterface*>( in.get() );
1071  if ( intf )
1072  {
1073  size = intf->getFileSize();
1074  }
1075  else
1076  {
1077  in->seekg(0, std::ios_base::end);
1078  size = (ossim_int64)in->tellg();
1079  }
1080  }
1081  }
1082 
1083  return size;
1084 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
static StreamFactoryRegistry * instance()
std::string::size_type size() const
Definition: ossimString.h:405
bool isUrl() const
virtual ossim_int64 getFileSize() const =0
Pure virtual file size method.
long long ossim_int64
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

◆ getPathSeparator()

char ossimFilename::getPathSeparator ( ) const
Returns
The path separator.

Definition at line 1412 of file ossimFilename.cpp.

References OSSIM_FILENAME_PATH_SEPARATOR.

1413 {
1415 }
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ getTimes()

bool ossimFilename::getTimes ( ossimLocalTm accessTime,
ossimLocalTm modTime,
ossimLocalTm createTime 
) const

Definition at line 375 of file ossimFilename.cpp.

References ossimString::c_str(), exists(), expand(), isDir(), and Read.

378 {
379  if(!expand().exists()) return false;
380 
381 #if defined(_WIN32)
382  // we must use different methods for the files and directories under
383  // Windows as CreateFile(GENERIC_READ) doesn't work for the directories and
384  // CreateFile(FILE_FLAG_BACKUP_SEMANTICS) works -- but only under NT and
385  // not 9x
386  bool ok;
387  FILETIME ftAccess, ftCreate, ftWrite;
388  if ( isDir() )
389  {
390  ok = ossimGetDirectoryTimes(expand().c_str(),
391  &ftAccess, &ftCreate, &ftWrite);
392  ok = false;
393  }
394  else // file
395  {
396  ossimFileHandle fh(expand().c_str(), ossimFileHandle::Read);
397  if ( fh.isOk() )
398  {
399  ok = ::GetFileTime(fh,
400  createTime ? &ftCreate : NULL,
401  accessTime ? &ftAccess : NULL,
402  modTime ? &ftWrite : NULL) != 0;
403  }
404  else
405  {
406  ok = false;
407  }
408  }
409 
410  if ( ok )
411  {
412  if ( createTime )
413  {
414  convertFileTimeToOssim(*createTime, ftCreate);
415  }
416  if ( accessTime )
417  {
418  convertFileTimeToOssim(*accessTime, ftAccess);
419  }
420  if ( modTime )
421  {
422  convertFileTimeToOssim(*modTime, ftWrite);
423  }
424 
425  return true;
426  }
427 #else
428  struct stat sbuf;
429  stat(c_str(), &sbuf);
430  if ( stat( expand().c_str(), &sbuf) == 0 )
431  {
432  if ( accessTime )
433  {
434  *accessTime = ossimLocalTm(sbuf.st_atime);
435  }
436  if ( modTime )
437  {
438  *modTime = ossimLocalTm(sbuf.st_mtime);
439  }
440  if ( createTime )
441  {
442  *createTime = ossimLocalTm(sbuf.st_ctime);
443  }
444  return true;
445  }
446 #endif // platforms
447 
448 
449  return false;
450 }
ossimFilename expand() const
Method to do file name expansion.
bool isDir() const
bool exists() const
Definition: vpftable.h:80
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

◆ isDir()

bool ossimFilename::isDir ( ) const

Definition at line 683 of file ossimFilename.cpp.

References ossimString::beforePos(), ossimString::c_str(), ossimString::empty(), and ossimString::size().

Referenced by ossimSingleImageChain::addImageHandler(), ossimDirectoryTree::checkToPushDirectory(), copyFileTo(), ossimToolClient::execute(), ossimDirectoryTree::getFirst(), getTimes(), ossimDtedElevationDatabase::inititializeExtension(), ossimArcInfoGridWriter::isOpen(), ossim::JsonConfig::JsonConfig(), ossimElevManager::loadElevationPath(), ossimInit::loadPlugins(), ossimGeoidNgs::open(), ossimArcInfoGridWriter::open(), ossimGeneralRasterElevationDatabase::openGeneralRasterDirectory(), ossimImageHandlerFactory::openSrcRecord(), ossimDemTool::ossimDemTool(), ossimIgen::outputProduct(), ossimDirectoryData::read(), ossimDemToolConfig::readConfig(), ATP::AtpConfig::readConfig(), remove(), ossimGeneralRasterElevFactory::setDirectory(), ossimImageHandler::setSupplementaryDirectory(), and wildcardRemove().

684 {
685  if ( empty() )
686  {
687  return false;
688  }
689 
690  ossimFilename temp = c_str();
691  const char& lastChar = temp[temp.size()-1];
692  if ( lastChar == '/' || lastChar == '\\' )
693  {
694  temp = temp.beforePos(temp.size() - 1);
695  }
696 
697 #if defined(_WIN32)
698 
699  struct _stat sbuf;
700  if ( _stat(temp.c_str(), &sbuf ) == -1)
701  return false;
702  return (_S_IFDIR & sbuf.st_mode ? true : false);
703 #else
704  struct stat sbuf;
705  if (stat(temp.c_str(), &sbuf) == -1)
706  return false;
707  return (S_ISDIR(sbuf.st_mode));
708 #endif
709 }
std::string::size_type size() const
Definition: ossimString.h:405
ossimString beforePos(std::string::size_type pos) 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
bool empty() const
Definition: ossimString.h:411

◆ isExecutable()

bool ossimFilename::isExecutable ( ) const

Definition at line 755 of file ossimFilename.cpp.

References ossimString::c_str(), and OSSIM_EXE.

756 {
757 #if defined(_WIN32)
758 
759  struct _stat sbuf;
760  if ( _stat(c_str(), &sbuf ) == -1)
761  return false;
762  return (_S_IEXEC & sbuf.st_mode ? true : false);
763 #else
764  return (access(c_str(), ossimFilename::OSSIM_EXE) == 0);
765 #endif
766 }
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

◆ isFile()

bool ossimFilename::isFile ( ) const

Definition at line 668 of file ossimFilename.cpp.

References ossimString::c_str().

Referenced by ossimDynamicLibrary::load(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimElevationDatabaseFactory::open(), and ossimDirectoryData::read().

669 {
670 #if defined(_WIN32)
671  struct _stat sbuf;
672  if ( _stat(c_str(), &sbuf ) == -1)
673  return false;
674  return (_S_IFMT & sbuf.st_mode ? true : false);
675 #else
676  struct stat sbuf;
677 
678  stat(c_str(), &sbuf);
679  return ((sbuf.st_mode & S_IFMT) == S_IFREG);
680 #endif
681 }
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

◆ isReadable()

bool ossimFilename::isReadable ( ) const

Definition at line 711 of file ossimFilename.cpp.

References ossimString::c_str(), and OSSIM_READ.

Referenced by ossimVerticesFinderTool::initialize(), ossimEpsgProjectionDatabase::initialize(), ossimChipProcTool::loadDemFiles(), ossimWktProjectionFactory::loadRecords(), ossimRangeDomeTileSource::open(), and ossimBatchTest::processConfigList().

712 {
713 #if defined(_WIN32)
714 
715  struct _stat sbuf;
716  if ( _stat(c_str(), &sbuf ) == -1)
717  return false;
718  return (_S_IREAD & sbuf.st_mode ? true : false);
719 #else
720  return (access(c_str(), ossimFilename::OSSIM_READ) == 0);
721 #endif
722 }
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

◆ isRelative()

bool ossimFilename::isRelative ( ) const

Checks whether file name is relative or absolute.

Returns
true if file name has a relative path, false if absolute.
Note
This will return true if file name is empty.

Definition at line 1359 of file ossimFilename.cpp.

References ossimString::begin(), ossimString::c_str(), ossimRegExp::find(), and ossimString::size().

Referenced by expand(), ossimEpsgProjectionDatabase::initialize(), ossimWktProjectionFactory::loadRecords(), and needsExpansion().

1360 {
1361  bool result = true;
1362  if (size())
1363  {
1364  //---
1365  // Look for unix "/"...
1366  // ESH: Look for Windows "\" (with prepending escape character \)
1367  //---
1368  if ( (*(begin()) == '/') || (*(begin()) == '\\') )
1369  {
1370  result = false;
1371  }
1372  else
1373  {
1374  // Look for windows drive
1375  ossimRegExp regEx("^([a-z|A-Z])+:");
1376  if ( regEx.find(c_str()) == true)
1377  {
1378  result = false;
1379  }
1380  }
1381  }
1382  return result;
1383 }
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420
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

◆ isUrl()

bool ossimFilename::isUrl ( ) const

Definition at line 724 of file ossimFilename.cpp.

References ossimString::m_str.

Referenced by exists(), fileSize(), and needsExpansion().

725 {
726  bool result = false;
727  if ( m_str.size() )
728  {
729  //---
730  // Must have at least room for a protocol and "://", e.g.
731  // "s3://my_bucket/data1/foo.tif
732  //---
733  std::size_t found = m_str.find( std::string("://") );
734  if ( ( found != std::string::npos ) && ( found > 1 ) )
735  {
736  result = true;
737  }
738  }
739  return result;
740 }
std::string m_str
Definition: ossimString.h:733

◆ isWriteable()

bool ossimFilename::isWriteable ( ) const

Definition at line 742 of file ossimFilename.cpp.

References ossimString::c_str(), and OSSIM_WRITE.

Referenced by ossimToolClient::setProductFilePath().

743 {
744 #if defined(_WIN32)
745 
746  struct _stat sbuf;
747  if ( _stat(c_str(), &sbuf ) == -1)
748  return false;
749  return (_S_IWRITE & sbuf.st_mode ? true : false);
750 #else
751  return (access(c_str(), ossimFilename::OSSIM_WRITE) == 0);
752 #endif
753 }
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

◆ lastAccessed()

ossim_int64 ossimFilename::lastAccessed ( ) const

Time in seconds since last accessed.

Returns
The number of seconds since last accessed or -1 if file does not exist.

Definition at line 453 of file ossimFilename.cpp.

References ossimString::c_str(), exists(), expand(), and ossim::getTime().

454 {
455  ossim_int64 result = -1;
456 
457  if( expand().exists() )
458  {
459  ossim_int64 currentTime = ossim::getTime();
460 
461 #if defined(_WIN32)
462  cerr << "ossimFilename::lastAccessed() not implemented for windows!" << endl;
463 #else
464  struct stat sbuf;
465  stat(c_str(), &sbuf);
466  if ( stat( expand().c_str(), &sbuf) == 0 )
467  {
468  time_t atime = sbuf.st_atime; // This cast to seconds(time_t).
469  result = currentTime - (ossim_int64)atime;
470  }
471 #endif // platforms
472  }
473 
474  return result;
475 }
OSSIM_DLL ossim_int64 getTime()
Gets the current time.
ossimFilename expand() const
Method to do file name expansion.
bool exists() const
long long ossim_int64
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

◆ merge()

void ossimFilename::merge ( const ossimString drivePart,
const ossimString pathPart,
const ossimString filePart,
const ossimString extPart 
)

Definition at line 976 of file ossimFilename.cpp.

References dirCat(), and ossimFilename().

Referenced by append(), ossimImageHandler::getFilenameWithNoExtension(), noExtension(), setDrive(), setExtension(), setFile(), and setPath().

980 {
981  ossimFilename result = drivePart;
982 
983  if(pathPart != "")
984  {
985  result = result.dirCat(ossimFilename(pathPart));
986  }
987 
988  if(filePart!="")
989  {
990  result = result.dirCat(ossimFilename(filePart));
991  }
992 
993  if(extPart != "")
994  {
995  result += ".";
996  result += extPart;
997  }
998 
999  *this = result;
1000 }
ossimFilename dirCat(const ossimFilename &file) const

◆ native()

std::string ossimFilename::native ( ) const
Returns
This as a string converted to native slashes.

Definition at line 1448 of file ossimFilename.cpp.

References ossimString::m_str, OSSIM_FILENAME_PATH_SEPARATOR, and OSSIM_NATIVE_PATH_SEPARATOR.

1449 {
1450 #if defined(_WIN32)
1451  std::string s = m_str;
1452  std::replace( s.begin(), s.end(),OSSIM_FILENAME_PATH_SEPARATOR, OSSIM_NATIVE_PATH_SEPARATOR );
1453  return s;
1454 #else
1455  return m_str;
1456 #endif
1457 }
std::string m_str
Definition: ossimString.h:733
static const char OSSIM_NATIVE_PATH_SEPARATOR
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ needsExpansion()

bool ossimFilename::needsExpansion ( ) const

Method to check if expansion is needed.

This checks if file isRelative() first if isRelative is false (has absolute path) it then walks the file and looks for '$'.

Returns
true if file name is relative or has environment vars.
Note
This will return false if file name is empty.

Definition at line 1385 of file ossimFilename.cpp.

References isRelative(), isUrl(), and ossimString::m_str.

Referenced by expand().

1386 {
1387  bool result = false;
1388  if ( m_str.size() )
1389  {
1390  // Do not expand URLs.
1391  if ( isUrl() == false )
1392  {
1393  result = isRelative();
1394  if (result == false)
1395  {
1396  // Check for '$'
1397  std::string::size_type pos = m_str.find('$', 0);
1398  {
1399  if (pos != std::string::npos)
1400  {
1401  // found '$'
1402  result = true;
1403  }
1404  }
1405 
1406  }
1407  }
1408  }
1409  return result;
1410 }
std::string m_str
Definition: ossimString.h:733
bool isUrl() const
bool isRelative() const
Checks whether file name is relative or absolute.

◆ noExtension()

ossimFilename ossimFilename::noExtension ( ) const
Returns
"/data/images/t1" if file is "/data/images/t1.tif".
Note
The '.' (dot) is not returned.

Definition at line 852 of file ossimFilename.cpp.

References ossimString::clear(), merge(), and split().

Referenced by ossimBitMaskWriter::connectMyInputTo(), ossimHdf5Tool::execute(), ossimGdalTileSource::getExternalImageGeometryFromXml(), ossimKmlSuperOverlayReader::getTopLevelKmlFileInfo(), ossimGdalOgrVectorAnnotation::loadExternalImageGeometryFromXml(), main(), ossimImageUtil::substituteFileStrings(), and ossimImageFileWriter::writeReadmeFile().

853 {
854  ossimString drivePart;
855  ossimString pathPart;
856  ossimString filePart;
857  ossimString extPart;
858 
859  split(drivePart, pathPart, filePart, extPart);
860 
861  extPart.clear();
862 
863  ossimFilename result;
864 
865  result.merge(drivePart, pathPart, filePart, extPart);
866 
867  return result;
868 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ operator=()

const ossimFilename & ossimFilename::operator= ( const ossimFilename f)

Definition at line 249 of file ossimFilename.cpp.

References ossimString::m_str.

250 {
251  if ( this != &f )
252  {
253  m_str = f.m_str;
254  }
255  return *this;
256 }
std::string m_str
Definition: ossimString.h:733

◆ operator==() [1/3]

bool ossimFilename::operator== ( const ossimFilename rhs) const

Definition at line 268 of file ossimFilename.cpp.

References ossimString::operator==.

269 {
270  return ossimString::operator==(rhs);
271 }
friend OSSIM_DLL bool operator==(const char *lhs, const ossimString &rhs)
Definition: ossimString.h:955

◆ operator==() [2/3]

bool ossimFilename::operator== ( const ossimString rhs) const

Definition at line 273 of file ossimFilename.cpp.

References ossimString::operator==.

274 {
275  return ossimString::operator==(rhs);
276 }
friend OSSIM_DLL bool operator==(const char *lhs, const ossimString &rhs)
Definition: ossimString.h:955

◆ operator==() [3/3]

bool ossimFilename::operator== ( const char *  rhs) const

Definition at line 278 of file ossimFilename.cpp.

References ossimString::operator==.

279 {
280  return ossimString::operator ==(rhs);
281 }
friend OSSIM_DLL bool operator==(const char *lhs, const ossimString &rhs)
Definition: ossimString.h:955

◆ path()

ossimFilename ossimFilename::path ( ) const
Returns
"/data/images" if file is "/data/images/t1.tif".

Definition at line 788 of file ossimFilename.cpp.

References ossimString::m_str, NIL, OSSIM_FILENAME_PATH_SEPARATOR, and ossimFilename().

Referenced by ossimSingleImageChain::addImageHandler(), ossimImageHandler::createDefaultValidVerticesFilename(), ossimplugins::ossimPluginProjectionFactory::createProjection(), ossimToolClient::execute(), ossimSensorModelFactory::findCoarseGrid(), ossimLandsatTopoCorrectionFilter::findLandsatHeader(), ossimplugins::ossimTerraSarModel::findTSXLeader(), ossimIgenGenerator::generateGeoTiledSpecList(), ossimIgenGenerator::generatePixelTiledSpecList(), ossimBandSeparateHandler::getBandFileNames(), ossimH5ImageHandler::getLatLonDatasets(), ossimVpfDatabase::getLibraryNamesFullPath(), ossimVpfDatabase::getPath(), ossimRpfToc::getRootDirectory(), ossimRpfToc::getSourceTocFile(), ossimVerticesFinderTool::initialize(), ossimInit::initializePlugins(), ossimplugins::ossimRadarSat2Model::InitLut(), ossimArcInfoGridWriter::open(), ossimTiffWorld::open(), ossimERSTileSource::open(), ossimplugins::ossimRadarSat2TiffReader::open(), ossimplugins::ossimTerraSarTiffReader::open(), ossimplugins::ossimSpot6Model::open(), ossimplugins::ossimPleiadesModel::open(), ossimplugins::ossimRadarSat2RPCModel::open(), ossimplugins::ossimRadarSat2Model::open(), ossimVpfDatabase::openDatabase(), ossimImageHandlerFactory::openSrcRecord(), ossimImageHandler::openValidVertices(), ossimIgen::outputProduct(), ossimBatchTest::processConfigList(), ossimKeywordlist::readPreprocDirective(), ossimAlphaSensorSupportData::readSupportFiles(), ossimImageHandler::setSupplementaryDirectory(), ossimSpot5Model::setupOptimizer(), ossimplugins::ossimFormosatModel::setupOptimizer(), split(), ossimImageUtil::substituteFileStrings(), and wildcardRemove().

789 {
790  // finds the last occurrence of the given string; in this case '/';
791  std::string::size_type pos = m_str.rfind(OSSIM_FILENAME_PATH_SEPARATOR);
792 
793  if (pos == 0)
795  if (pos == std::string::npos)
796  {
797  // We got to the end of the file and did not find a path separator.
798  return ossimFilename::NIL;
799  }
800 
801  return ossimFilename(m_str.substr(0, pos));
802 }
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
std::string m_str
Definition: ossimString.h:733
static const char OSSIM_FILENAME_PATH_SEPARATOR

◆ remove() [1/2]

bool ossimFilename::remove ( const ossimFilename pathname)
static

Removes pathname from filesystem if supported by platform.

If pathname is a directory it will only be removed if empty. If supported will set errno and output equivalent string if one occurs.

Returns
true on success, false on error.

Definition at line 1171 of file ossimFilename.cpp.

References ossimString::c_str(), and isDir().

Referenced by ossimGpkgWriter::open(), ossimGdalWriter::postProcessOutput(), rename(), and ossimGeoTiff::writeJp2GeotiffBox().

1172 {
1173  bool result = true;
1174 
1175 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) || \
1176  defined(__GNUWIN32__) || defined(_MSC_VER)
1177 
1178  // Note: not sure if these work on all of the above flavors. drb - 14 Sep. 2011.
1179  if(pathname.isDir())
1180  {
1181  // Note this only removes empty directories.
1182  result = ( RemoveDirectory( pathname.c_str() ) != 0 );
1183  }
1184  else
1185  {
1186  result = ( DeleteFile( pathname.c_str() ) != 0 );
1187  }
1188 #else /* Unix flavor from unistd.h. */
1189  if(pathname.isDir())
1190  {
1191  result = ( rmdir( pathname.c_str() ) == 0 );
1192  }
1193  else
1194  {
1195  result = ( unlink( pathname.c_str() ) == 0 );
1196  }
1197 #endif
1198 
1199  return result;
1200 }
bool isDir() 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

◆ remove() [2/2]

bool ossimFilename::remove ( ) const

Definition at line 1279 of file ossimFilename.cpp.

1280 {
1281  return ossimFilename::remove(*this);
1282 }
bool remove() const

◆ rename()

bool ossimFilename::rename ( const ossimFilename destFile,
bool  overwriteDestinationFlag = true 
) const

Definition at line 1250 of file ossimFilename.cpp.

References ossimString::c_str(), exists(), ossimNotify(), ossimNotifyLevel_WARN, remove(), and ossimString::string().

Referenced by ossimKmlSuperOverlayReader::getTopLevelKmlFileInfo().

1251 {
1252  bool result = true;
1253  if ( this->string() != destFile.string() )
1254  {
1255  if ( overwriteDestinationFlag && destFile.exists() )
1256  {
1257  destFile.remove();
1258  }
1259 
1260  if ( destFile.exists() == false )
1261  {
1262  // std::rename from cstdio returns 0 on success.
1263  if ( std::rename(this->c_str(), destFile.c_str()) != 0 )
1264  {
1265  result = false;
1266  }
1267  }
1268  else
1269  {
1271  << "ossimFilenam::rename WARNING:"
1272  << "\nDestination File Exists: " << destFile << std::endl;
1273  result = false;
1274  }
1275  }
1276  return result;
1277 }
static bool remove(const ossimFilename &pathname)
Removes pathname from filesystem if supported by platform.
bool exists() 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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ setDrive()

ossimFilename & ossimFilename::setDrive ( const ossimString d)

Sets the file path and drive.

Input: the drive to be set (this should come from the user's preferences) Example: "x:" Given: "/filepath/file.ext"

Returns
"c:\filepath\file.ext".

Definition at line 900 of file ossimFilename.cpp.

References merge(), and split().

901 {
902  ossimString drivePart;
903  ossimString pathPart;
904  ossimString filePart;
905  ossimString extPart;
906 
907  split(drivePart,
908  pathPart,
909  filePart,
910  extPart);
911 
912  merge(d,
913  pathPart,
914  filePart,
915  extPart);
916 
917  return *this;
918 }
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ setExtension()

ossimFilename & ossimFilename::setExtension ( const ossimString e)

Sets the extension of a file name.

Given: ossimFilename f = "foo"; f.setExtension("tif"); f now equals "foo.tif"

Given: ossimFilename f = "foo.jpg"; f.setExtension("tif"); f now equals "foo.tif"

Given: ossimFilename f = "foo.jpg"; f.setExtension(".tif"); f now equals "foo.tif"

Given: ossimFilename f = "foo."; ossimFilename f2; f2 = f.setExtension("tif"); f now equals "foo.tif" f2 now equals "foo.tif"

Parameters
eExtension to add or replace.
Returns
a reference to this.

Definition at line 870 of file ossimFilename.cpp.

References ossimString::begin(), ossimString::end(), merge(), ossimString::ossimString(), and split().

Referenced by ossimSingleImageChain::addHistogramRemapper(), ossimBitMaskWriter::connectMyInputTo(), ossimSensorModelFactory::createProjection(), ossimplugins::ossimPluginProjectionFactory::createProjection(), ossimMapProjectionFactory::createProjection(), ossimSrtmElevationDatabase::createRelativePath(), ossimShorelineTool::execute(), ossimSubImageTool::execute(), ossimSensorModelFactory::findCoarseGrid(), ossimLandsatTopoCorrectionFilter::findLandsatHeader(), ossimQuickbirdRpcModel::findSupportFile(), ossimDtedHandler::gatherStatistics(), ossimTempFilename::generate(), ossimIgenGenerator::generateGeoTiledSpecList(), ossimIgenGenerator::generatePixelTiledSpecList(), ossimImageHandler::getFilenameWithNoExtension(), ossimMrSidReader::getGeoProjection(), ossimQbTileFilesHandler::getImageGeometry(), ossimGeneralRasterTileSource::getImageGeometry(), ossimGdalOverviewBuilder::getOutputFile(), ossimCcfTileSource::isEcgGeom(), ossimDemUtil::isUsgsDem(), ossimGdalOgrVectorAnnotation::loadExternalGeometryFile(), ossimDemTool::loadJSON(), ossimDtedTileSource::loadMetaData(), ossimGdalOgrVectorAnnotation::loadOmdFile(), ossimPointCloudImageHandlerFactory::open(), ossimEnviInfo::open(), ossimQuickbirdMetaData::open(), ossimplugins::ossimPleiadesModel::open(), ossimAdrgHeader::ossimAdrgHeader(), ossimQuickbirdRpcModel::parseMetaData(), ossimQuickbirdRpcModel::parseNitfFile(), ossimQuickbirdRpcModel::parseRpcData(), ossimQuickbirdRpcModel::parseTileData(), ossimChipProcTool::processRemainingArgs(), ossimGeneralRasterElevHandler::setFilename(), ossimSpot5Model::setupOptimizer(), ossimplugins::ossimFormosatModel::setupOptimizer(), ossimImageData::write(), ossimImageFileWriter::writeEnviHeaderFile(), ossimImageFileWriter::writeErsHeaderFile(), ossimImageFileWriter::writeExternalGeometryFile(), ossimImageFileWriter::writeFgdcFile(), ossimImageFileWriter::writeHistogramFile(), ossimImageFileWriter::writeJpegWorldFile(), ossimImageFileWriter::writeOverviewFile(), ossimImageFileWriter::writeTiffWorldFile(), and ossimImageFileWriter::writeWorldFile().

871 {
872  ossimString newExtPart = e;
873 
874  //---
875  // If e has a dot "." in the front of it strip it off...
876  //---
877  if ( (e.begin() != e.end()) && ((*(e.begin())) == '.') )
878  {
879  newExtPart = ossimString(e.begin() + 1, e.end());
880  }
881 
882  ossimString drivePart;
883  ossimString pathPart;
884  ossimString filePart;
885  ossimString extPart;
886 
887  split(drivePart,
888  pathPart,
889  filePart,
890  extPart);
891 
892  merge(drivePart,
893  pathPart,
894  filePart,
895  newExtPart);
896 
897  return *this;
898 }
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
std::string::iterator end()
Definition: ossimString.h:423
ossimString()
default constructor
Definition: ossimString.h:31
std::string::iterator begin()
Definition: ossimString.h:420
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ setFile()

ossimFilename & ossimFilename::setFile ( const ossimString f)

Definition at line 940 of file ossimFilename.cpp.

References merge(), and split().

Referenced by ossimplugins::ossimAlosPalsarModel::findAlosPalsarData(), ossimplugins::ossimAlosPalsarModel::findAlosPalsarLeader(), ossimSensorModelFactory::findCoarseGrid(), ossimplugins::ossimErsSarModel::findErsLeader(), and ossimplugins::ossimPleiadesModel::open().

941 {
942  ossimString drivePart;
943  ossimString pathPart;
944  ossimString filePart;
945  ossimString extPart;
946 
947  split(drivePart,
948  pathPart,
949  filePart,
950  extPart);
951 
952  merge(drivePart,
953  pathPart,
954  f,
955  extPart);
956 
957  return *this;
958 }
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ setPath()

ossimFilename & ossimFilename::setPath ( const ossimString p)

Definition at line 920 of file ossimFilename.cpp.

References merge(), and split().

Referenced by ossimBandSeparateHandler::getBandFileNames(), ossimDemTool::ossimDemTool(), ossimBatchTest::processConfigList(), ossimDemToolConfig::readConfig(), and ATP::AtpConfig::readConfig().

921 {
922  ossimString drivePart;
923  ossimString pathPart;
924  ossimString filePart;
925  ossimString extPart;
926 
927  split(drivePart,
928  pathPart,
929  filePart,
930  extPart);
931 
932  merge(drivePart,
933  p,
934  filePart,
935  extPart);
936 
937  return *this;
938 }
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)

◆ setTimes()

bool ossimFilename::setTimes ( ossimLocalTm accessTime,
ossimLocalTm modTime,
ossimLocalTm createTime 
) const

Writes f to the output stream os.

Definition at line 314 of file ossimFilename.cpp.

References ossimLocalTm::getTicks(), and Write.

Referenced by touch().

321 {
322 #if defined(_WIN32)
323  if(isDir())
324  {
325  // need to implement this later
326  return false;
327  }
328  else
329  {
330  ossimFileHandle fh(this->expand(), ossimFileHandle::Write);
331  if(fh.isOk())
332  {
333  FILETIME ftAccess, ftCreate, ftWrite;
334 
335  if ( createTime )
336  {
337  convertOssimToFileTime(&ftCreate, *createTime);
338  }
339  if ( accessTime )
340  {
341  convertOssimToFileTime(&ftAccess, *accessTime);
342  }
343  if ( modTime )
344  {
345  convertOssimToFileTime(&ftWrite, *modTime);
346  }
347  if ( ::SetFileTime(fh,
348  createTime ? &ftCreate : NULL,
349  accessTime ? &ftAccess : NULL,
350  modTime ? &ftWrite : NULL) )
351  {
352  return true;
353  }
354  }
355  }
356 #else
357  if ( !accessTime && !modTime )
358  {
359  // can't modify the creation time anyhow, don't try
360  return true;
361  }
362  utimbuf utm;
363  utm.actime = accessTime ? accessTime->getTicks() : modTime->getTicks();
364  utm.modtime = modTime ? modTime->getTicks() : accessTime->getTicks();
365  if ( utime(expand().c_str(), &utm) == 0 )
366  {
367  return true;
368  }
369 
370 #endif
371 
372  return false;
373 }
ossimFilename expand() const
Method to do file name expansion.
bool isDir() const
Definition: vpftable.h:80
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
time_t getTicks() const
getTicks() will call getEpoc.
Definition: ossimDate.cpp:624

◆ split()

void ossimFilename::split ( ossimString drivePart,
ossimString pathPart,
ossimString filePart,
ossimString extPart 
) const

Definition at line 961 of file ossimFilename.cpp.

References drive(), ext(), fileNoExtension(), path(), and ossimString::substitute().

Referenced by append(), ossimImageHandler::getFilenameWithNoExtension(), noExtension(), setDrive(), setExtension(), setFile(), and setPath().

965 {
966  drivePart = drive();
967  pathPart = path();
968  if(drivePart != "")
969  {
970  pathPart = pathPart.substitute(drivePart, "");
971  }
972  filePart = fileNoExtension();
973  extPart = ext();
974 }
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
ossimFilename fileNoExtension() const
ossimString ext() const
ossimFilename path() const
ossimFilename drive() const

◆ touch()

bool ossimFilename::touch ( ) const

Definition at line 477 of file ossimFilename.cpp.

References ossimString::c_str(), expand(), and setTimes().

478 {
479 #if defined( _WIN32 )
480  ossimDate now;
481 
482  return setTimes(&now, &now, 0);
483 
484 #else
485  if ( utime(expand().c_str(), NULL) == 0 )
486  {
487  return true;
488  }
489 
490  return false;
491 #endif
492 }
ossimFilename expand() const
Method to do file name expansion.
bool setTimes(ossimLocalTm *accessTime, ossimLocalTm *modTime, ossimLocalTm *createTime) const
Writes f to the output stream os.
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

◆ wildcardRemove() [1/2]

bool ossimFilename::wildcardRemove ( const ossimFilename pathname)
static

Will use a wildcard remove.

NOTE: This is in a regular expression format so if you want all files with prefix myfile to be erased then you would give it <path>/myfile.*

The . here is a regular expression '.' character which says any character and the * "is any number of"

Definition at line 1202 of file ossimFilename.cpp.

References ossimString::c_str(), file(), ossimDirectory::findAllFilesThatMatch(), isDir(), ossimDirectory::open(), ossimFilename(), and path().

1203 {
1204  std::vector<ossimFilename> fileListToRemove;
1205  ossimFilename tempPathname = pathname;
1206 
1207  if(!tempPathname.isDir())
1208  {
1209  ossimFilename file = tempPathname.file();
1210  ossimFilename path = tempPathname.path();
1211  if(path == "")
1212  {
1213  path = ".";
1214  }
1215  ossimDirectory dir;
1216  if(dir.open(path))
1217  {
1218  dir.findAllFilesThatMatch(fileListToRemove,
1219  file.c_str());
1220  }
1221  else
1222  {
1223  }
1224  }
1225  else
1226  {
1227  fileListToRemove.push_back(ossimFilename(pathname));
1228  }
1229  ossim_uint32 idx = 0;
1230  bool result = true;
1231  for(idx = 0; idx < fileListToRemove.size(); ++idx)
1232  {
1233 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) || \
1234  defined(__GNUWIN32__) || defined(_MSC_VER)
1235 
1236  if(remove(fileListToRemove[idx].c_str()) != 0)
1237  {
1238  result = false;
1239  }
1240 #else
1241  if (unlink(fileListToRemove[idx]) == -1)
1242  {
1243  result = false;
1244  }
1245 #endif /* HAVE_UNISTD_H */
1246  }
1247  return result;
1248 }
void findAllFilesThatMatch(std::vector< ossimFilename > &result, const ossimString &regularExpressionPattern, int flags=OSSIM_DIR_DEFAULT)
bool isDir() const
unsigned int ossim_uint32
bool open(const ossimFilename &dir)
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
ossimFilename path() const

◆ wildcardRemove() [2/2]

bool ossimFilename::wildcardRemove ( ) const

Definition at line 1284 of file ossimFilename.cpp.

Referenced by ossimTempFilename::~ossimTempFilename().

1285 {
1286  return ossimFilename::wildcardRemove(*this);
1287 }
bool wildcardRemove() const

Member Data Documentation

◆ NIL

const ossimFilename ossimFilename::NIL =("")
static

◆ OSSIM_FILENAME_PATH_SEPARATOR

const char ossimFilename::OSSIM_FILENAME_PATH_SEPARATOR = '/'
staticprotected

◆ OSSIM_NATIVE_PATH_SEPARATOR

const char ossimFilename::OSSIM_NATIVE_PATH_SEPARATOR = '/'
staticprotected

since windows uses \ for path separation and unix / we need to be consistent.

Definition at line 284 of file ossimFilename.h.

Referenced by native().


The documentation for this class was generated from the following files: