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

#include <ossimTempFilename.h>

Inheritance diagram for ossimTempFilename:
ossimFilename ossimString

Public Member Functions

 ossimTempFilename (const ossimString &tempDir="", const ossimString &prefix="", const ossimString &extension="", bool autodelete=true, bool useWildcardDelete=true)
 
void generateRandomFile ()
 
void generateRandomDir ()
 
 ~ossimTempFilename ()
 
- Public Member Functions inherited from ossimFilename
 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...
 

Protected Member Functions

void generate (bool createAsDirectoryFlag)
 
- Protected Member Functions inherited from ossimFilename
void converPathSeparator ()
 Converts slashes of this to internal '/' format. More...
 

Protected Attributes

ossimString theTempDir
 
ossimString thePrefix
 
ossimString theExtension
 
bool theAutoDeleteFlag
 
bool theWildCardDeleteFlag
 
- Protected Attributes inherited from ossimString
std::string m_str
 

Additional Inherited Members

- Public Types inherited from ossimFilename
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
 
- Static Public Member Functions inherited from ossimFilename
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 inherited from ossimFilename
static const ossimFilename NIL =("")
 This was taken from Wx widgets for performing touch and access date stamps. More...
 
- Static Protected Attributes inherited from ossimFilename
static const char OSSIM_NATIVE_PATH_SEPARATOR = '/'
 
static const char OSSIM_FILENAME_PATH_SEPARATOR = '/'
 

Detailed Description

Definition at line 18 of file ossimTempFilename.h.

Constructor & Destructor Documentation

◆ ossimTempFilename()

ossimTempFilename::ossimTempFilename ( const ossimString tempDir = "",
const ossimString prefix = "",
const ossimString extension = "",
bool  autodelete = true,
bool  useWildcardDelete = true 
)

Definition at line 20 of file ossimTempFilename.cpp.

25  :theTempDir(tempDir),
26  thePrefix(prefix),
27  theExtension(extension),
28  theAutoDeleteFlag(autodelete),
29  theWildCardDeleteFlag(useWildcardDelete)
30 {
31 }
ossimString theTempDir
ossimString theExtension

◆ ~ossimTempFilename()

ossimTempFilename::~ossimTempFilename ( )

Definition at line 33 of file ossimTempFilename.cpp.

References theAutoDeleteFlag, theWildCardDeleteFlag, and ossimFilename::wildcardRemove().

34 {
35  if(*((ossimFilename*)this) != "")
36  {
37 
39  {
41  {
42  wildcardRemove(*this + ".*");
43  }
44  else
45  {
46  remove();
47  }
48  }
49  }
50 }
bool wildcardRemove() const

Member Function Documentation

◆ generate()

void ossimTempFilename::generate ( bool  createAsDirectoryFlag)
protected

Definition at line 62 of file ossimTempFilename.cpp.

References ossimString::c_str(), ossimFilename::createDirectory(), ossimFilename::dirCat(), ossimFilename::exists(), ossimEnvironmentUtility::getEnvironmentVariable(), ossimEnvironmentUtility::instance(), ossimFilename::ossimFilename(), ossimFilename::setExtension(), theExtension, thePrefix, theTempDir, and ossimString::toString().

Referenced by generateRandomDir(), and generateRandomFile().

63 {
64  srand(time(0));
65  ossimString tempDirCopy = theTempDir;
66 
67  if(tempDirCopy == "")
68  {
70  if(tempDirCopy=="")
71  {
73  }
74  if(tempDirCopy == "")
75  {
76  if(ossimFilename("/tmp").exists())
77  {
78  tempDirCopy = "/tmp";
79  }
80  }
81  }
82 
83  int count = 0;
84  int randNumber1 = rand();
85  ossimFilename prefixDir = ossimFilename(tempDirCopy);
86  ossimFilename result = prefixDir.dirCat(thePrefix+
87  ossimString::toString(randNumber1));
88 
89  while((count < RAND_MAX)&&result.exists())
90  {
91  randNumber1 = rand();
92  result = prefixDir.dirCat(thePrefix+
93  ossimString::toString(randNumber1));
94 
95  ++count;
96  }
97 
98  if(theExtension != "")
99  {
100  result = result.setExtension(theExtension);
101  }
102  *((ossimFilename*)this) = result;
103  if(result != "")
104  {
105  if(createAsDirectoryFlag)
106  {
107  createDirectory();
108  }
109  else
110  {
111  std::ofstream out(result.c_str());
112  out.close();
113  }
114  }
115 }
ossimString theTempDir
static ossimString toString(bool aValue)
Numeric to string methods.
ossimString theExtension
bool exists() const
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
ossimString getEnvironmentVariable(const ossimString &variable) const
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
bool createDirectory(bool recurseFlag=true, int perm=0775) const

◆ generateRandomDir()

void ossimTempFilename::generateRandomDir ( )

Definition at line 57 of file ossimTempFilename.cpp.

References generate().

58 {
59  generate(true);
60 }
void generate(bool createAsDirectoryFlag)

◆ generateRandomFile()

void ossimTempFilename::generateRandomFile ( )

Definition at line 52 of file ossimTempFilename.cpp.

References generate().

53 {
54  generate(false);
55 }
void generate(bool createAsDirectoryFlag)

Member Data Documentation

◆ theAutoDeleteFlag

bool ossimTempFilename::theAutoDeleteFlag
protected

Definition at line 36 of file ossimTempFilename.h.

Referenced by ~ossimTempFilename().

◆ theExtension

ossimString ossimTempFilename::theExtension
protected

Definition at line 35 of file ossimTempFilename.h.

Referenced by generate().

◆ thePrefix

ossimString ossimTempFilename::thePrefix
protected

Definition at line 34 of file ossimTempFilename.h.

Referenced by generate().

◆ theTempDir

ossimString ossimTempFilename::theTempDir
protected

Definition at line 33 of file ossimTempFilename.h.

Referenced by generate().

◆ theWildCardDeleteFlag

bool ossimTempFilename::theWildCardDeleteFlag
protected

Definition at line 37 of file ossimTempFilename.h.

Referenced by ~ossimTempFilename().


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