/usr/include/ossim/base/ossimFilename.h is in libossim-dev 1.7.21-3ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | //*******************************************************************
//
// License: LGPL
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: Ken Melero
//
// Description: This class provides manipulation of filenames.
//
//*************************************************************************
// $Id: ossimFilename.h 14886 2009-07-15 15:40:50Z gpotts $
#ifndef ossimFilename_HEADER
#define ossimFilename_HEADER
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimString.h>
class ossimLocalTm;
class OSSIM_DLL ossimFilename : public ossimString
{
public:
enum AccessModes
{
OSSIM_READ_WRITE = 6,
OSSIM_READ = 4,
OSSIM_WRITE = 2,
OSSIM_EXE = 1, // The PC docs say that this is ignored
OSSIM_EXIST = 0
};
ossimFilename();
ossimFilename(const ossimFilename& src);
ossimFilename(const ossimString& src);
ossimFilename(const char* src);
template <class Iter> ossimFilename(Iter s, Iter e);
static const ossimFilename NIL;
bool operator == (const ossimFilename& rhs)const;
bool operator == (const ossimString& rhs)const;
bool operator == (const char* rhs)const;
void convertBackToForwardSlashes();
void convertForwardToBackSlashes();
bool setTimes(ossimLocalTm* accessTime,
ossimLocalTm* modTime,
ossimLocalTm* createTime)const;
bool getTimes(ossimLocalTm* accessTime,
ossimLocalTm* modTime,
ossimLocalTm* createTime)const;
bool touch()const;
/**
* Method to do file name expansion.
*
* Like: ~/docs will be expanded to /home/user/docs
*
* @return The expanded file name.
*
* @note METHOD IS NOT COMPLETE YET.
*/
ossimFilename expand() const;
// Methods to test ossimFilename for various states.
bool exists() const;
bool isFile() const;
bool isDir() const;
bool isReadable() const;
bool isWriteable() const;
bool isExecutable() const;
ossim_int64 fileSize() const;
// Methods to access parts of the ossimFilename.
/**
* @return "tif" if file is "/data/images/t1.tif".
*
* @note The '.' (dot) is not returned.
*/
ossimString ext() const;
/**
* @return @return "/data/images" if file is "/data/images/t1.tif".
*/
ossimFilename path() const;
/**
* @return @return "c:" if file is "c:\data\images\t1.tif".
*/
ossimFilename drive() const;
/**
* @return @return "t1.tif" if file is "/data/images/t1.tif".
*/
ossimFilename file() const;
/**
* @return @return "t1.tif" if file is "/data/images/t1.tif".
*/
ossimFilename fileNoExtension() const;
/**
* @return @return "/data/images/t1" if file is "/data/images/t1.tif".
*
* @note The '.' (dot) is not returned.
*/
ossimFilename noExtension() const;
/**
* 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"
*
* @param e Extension to add or replace.
*
* @returns a reference to this.
*/
ossimFilename& setExtension(const ossimString& e);
/**
* 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"
* @return @return "c:\filepath\file.ext".
*/
ossimFilename& setDrive(const ossimString& d);
ossimFilename& setPath(const ossimString& p);
ossimFilename& setFile(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);
/*!
* 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
*/
ossimFilename dirCat(const ossimFilename& file) const;
/*!
*/
bool createDirectory(bool recurseFlag=true,
int perm=0775)const;
/*!
* Removes pathname from filesystem if supported by platform.
* Return true on success, false on error.
* If supported will set errno and output equivalent string if one occurs.
*/
static bool remove(const ossimFilename& pathname);
/**
* 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"
*
*/
static bool wildcardRemove(const ossimFilename& pathname);
bool rename(const ossimFilename& destFile, bool overwriteDestinationFlag=true)const;
bool remove()const;
bool wildcardRemove()const;
/**
* @brief Copies this file to output file.
* @param outputFile File name to copy to.
* @return True on success, false on error.
*/
bool copyFileTo(const ossimFilename& ouputFile) const;
/**
* @brief Checks whether file name is relative or absolute.
*
* @return true if file name has a relative path, false if absolute.
*
* @note This will return true if file name is empty.
*/
bool isRelative() const;
/**
* @brief 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 '$'.
*
* @return true if file name is relative or has environment vars.
*
* @note This will return false if file name is empty.
*/
bool needsExpansion() const;
protected:
void convertToNative();
/*!
* since windows uses \ for path separation
* and unix / we need to be consistent.
*/
static const char thePathSeparator;
};
#endif
|