A class for handling file names. More...
#include <OpenFOAM/fileName.H>
A class for handling file names.
A fileName can be
The string::expand() method expands environment variables, etc,
Definition at line 69 of file fileName.H.
Public Types | |
enum | Type { UNDEFINED, FILE, DIRECTORY, LINK } |
Enumerations to handle file types and modes. More... |
Public Member Functions | |
fileName () | |
Construct null. | |
fileName (const fileName &) | |
Construct as copy. | |
fileName (const word &) | |
Construct as copy of word. | |
fileName (const string &) | |
Construct as copy of string. | |
fileName (const std::string &) | |
Construct as copy of std::string. | |
fileName (const char *) | |
Construct as copy of character array. | |
fileName (const wordList &) | |
Construct by concatenating elements of wordList separated by '/'. | |
fileName (Istream &) | |
Construct from Istream. | |
bool | clean () |
Cleanup file name. | |
fileName | clean () const |
Cleanup file name. | |
Type | type () const |
Return the file type: FILE, DIRECTORY or UNDEFINED. | |
word | name () const |
Return file name (part beyond last /) | |
fileName | path () const |
Return directory path name (part before last /) | |
fileName | lessExt () const |
Return file name without extension (part before last .) | |
word | ext () const |
Return file name extension (part after last .) | |
wordList | components (const char delimiter='/') const |
Return path components as wordList. | |
word | component (const size_type, const char delimiter='/') const |
Return a single component of the path. | |
const fileName & | operator= (const fileName &) |
const fileName & | operator= (const word &) |
const fileName & | operator= (const string &) |
const fileName & | operator= (const std::string &) |
const fileName & | operator= (const char *) |
![]() | |
string () | |
Construct null. | |
string (const std::string &) | |
Construct from std::string. | |
string (const char *) | |
Construct as copy of character array. | |
string (const char *, const size_type) | |
Construct as copy of specified number of characters. | |
string (const char) | |
Construct from a single character. | |
string (Istream &) | |
Construct from Istream. | |
size_type | count (const char) const |
Count and return the number of a given character in the string. | |
string & | replace (const string &oldStr, const string &newStr, size_type start=0) |
Replace first occurence of sub-string oldStr with newStr. | |
string & | replaceAll (const string &oldStr, const string &newStr, size_type start=0) |
Replace all occurences of sub-string oldStr with newStr. | |
string & | expand () |
Expand initial tildes and all occurences of environment variables. | |
bool | removeRepeated (const char) |
Remove repeated characters returning true if string changed. | |
string | removeRepeated (const char) const |
Return string with repeated characters removed. | |
bool | removeTrailing (const char) |
Remove trailing character returning true if string changed. | |
string | removeTrailing (const char) const |
Return string with trailing character removed. | |
string | operator() (const size_type i, const size_type n) const |
Return the sub-string from the i-th character for n characters. | |
string | operator() (const size_type n) const |
Return the sub-string from the first character for n characters. |
Static Public Member Functions | |
static bool | valid (char) |
Is this character valid for a fileName? | |
![]() | |
template<class String > | |
static bool | valid (const string &) |
Is this string type valid? | |
template<class String > | |
static bool | meta (const string &, const char quote='\\') |
Does this string have particular meta-characters? | |
template<class String > | |
static bool | stripInvalid (string &) |
Strip invalid characters from the given string. | |
template<class String > | |
static String | validate (const string &) |
Return a valid String from the given string. | |
template<class String > | |
static string | quotemeta (const string &, const char quote='\\') |
Return a String with quoted meta-characters from the given string. |
Static Public Attributes | |
static const char *const | typeName = "fileName" |
static int | debug |
static const fileName | null |
![]() |
Friends | |
Istream & | operator>> (Istream &, fileName &) |
Ostream & | operator<< (Ostream &, const fileName &) |
enum Type |
Enumerations to handle file types and modes.
Definition at line 82 of file fileName.H.
|
inline |
Construct null.
Definition at line 52 of file fileNameI.H.
Construct as copy.
Definition at line 57 of file fileNameI.H.
Construct as copy of word.
Definition at line 62 of file fileNameI.H.
Construct as copy of string.
Definition at line 68 of file fileNameI.H.
|
inline |
Construct as copy of std::string.
Definition at line 76 of file fileNameI.H.
|
inline |
Construct as copy of character array.
Definition at line 84 of file fileNameI.H.
Construct by concatenating elements of wordList separated by '/'.
Definition at line 40 of file fileName.C.
References forAll, and fileName::operator=().
Construct from Istream.
Definition at line 34 of file fileNameIO.C.
|
inlinestatic |
Is this character valid for a fileName?
Definition at line 94 of file fileNameI.H.
References Foam::isspace().
bool clean | ( | ) |
Cleanup file name.
eg, remove repeated slashes, etc.
Definition at line 71 of file fileName.C.
Referenced by fileName::clean().
Foam::fileName clean | ( | ) | const |
Cleanup file name.
eg, remove repeated slashes, etc.
Definition at line 166 of file fileName.C.
References fileName::clean().
Foam::fileName::Type type | ( | ) | const |
Return the file type: FILE, DIRECTORY or UNDEFINED.
Definition at line 51 of file fileName.C.
References Foam::type().
Referenced by Foam::cp(), Foam::mv(), fvMeshDistribute::printFieldInfo(), and Foam::rmDir().
Foam::word name | ( | ) | const |
Return file name (part beyond last /)
Definition at line 186 of file fileName.C.
Referenced by argList::argList(), probes::checkFieldTypes(), timeVaryingMappedFixedValueFvPatchField< Type >::checkTable(), Foam::cp(), Foam::mv(), processorPolyPatch::order(), triSurface::triSurfInstance(), timeVaryingMappedFixedValueFvPatchField< Type >::updateCoeffs(), PatchPostProcessing< CloudType >::write(), OBJsurfaceFormat< Face >::write(), partialWrite::write(), and STARCDsurfaceFormatCore::writeCase().
Foam::fileName path | ( | ) | const |
Return directory path name (part before last /)
Definition at line 212 of file fileName.C.
Referenced by probes::checkFieldTypes(), chemkinReader::chemkinReader(), Foam::cp(), isoSurface::isoSurface(), fieldValue::makeFile(), fieldMinMax::makeFile(), forces::makeFile(), Foam::mkDir(), surfMesh::removeFiles(), polyMesh::removeFiles(), PatchPostProcessing< CloudType >::write(), and triSurfaceMesh::writeObject().
Foam::fileName lessExt | ( | ) | const |
Return file name without extension (part before last .)
Definition at line 232 of file fileName.C.
Referenced by UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Face >::canRead(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Face >::New(), dlLibraryTable::open(), STARCDsurfaceFormat< Face >::read(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Face >::read(), Foam::readDir(), OBJsurfaceFormat< Face >::write(), STARCDsurfaceFormat< Face >::write(), and STARCDsurfaceFormatCore::writeCase().
Foam::word ext | ( | ) | const |
Return file name extension (part after last .)
Definition at line 248 of file fileName.C.
References word::null.
Referenced by UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Face >::canRead(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Face >::New(), dlLibraryTable::open(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Face >::read(), Foam::readDir(), triSurface::triSurface(), STLsurfaceFormat< Face >::write(), UnsortedMeshedSurface< Face >::write(), MeshedSurface< Face >::write(), and triSurface::write().
Foam::wordList components | ( | const char | delimiter = '/' | ) | const |
Return path components as wordList.
Definition at line 276 of file fileName.C.
References DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), and DynamicList< T, SizeInc, SizeMult, SizeDiv >::xfer().
Referenced by Foam::cp().
Foam::word component | ( | const size_type | cmpt, |
const char | delimiter = '/' |
||
) | const |
Return a single component of the path.
Definition at line 305 of file fileName.C.
Referenced by Foam::cp().
const Foam::fileName & operator= | ( | const fileName & | str | ) |
Definition at line 316 of file fileName.C.
Referenced by fileName::fileName().
const Foam::fileName & operator= | ( | const word & | str | ) |
Definition at line 323 of file fileName.C.
const Foam::fileName & operator= | ( | const string & | str | ) |
Definition at line 330 of file fileName.C.
const Foam::fileName & operator= | ( | const std::string & | str | ) |
Definition at line 338 of file fileName.C.
const Foam::fileName & operator= | ( | const char * | str | ) |
Definition at line 346 of file fileName.C.
|
static |
Reimplemented from string.
Definition at line 93 of file fileName.H.
|
static |
Reimplemented from string.
Definition at line 94 of file fileName.H.
|
static |
Reimplemented from string.
Definition at line 95 of file fileName.H.
Referenced by chemkinReader::chemkinReader(), Time::dbDir(), and IOobject::filePath().