A class for handling file names. More...
Public Member Functions | |
fileName () | |
Construct null. More... | |
fileName (const fileName &) | |
Copy constructor. More... | |
fileName (fileName &&) | |
Move constructor. More... | |
fileName (const word &) | |
Copy constructor of word. More... | |
fileName (const string &) | |
Copy constructor of string. More... | |
fileName (const std::string &) | |
Copy constructor of std::string. More... | |
fileName (const char *) | |
Copy constructor of character array. More... | |
fileName (const wordList &) | |
Construct by concatenating elements of wordList separated by '/'. More... | |
fileName (Istream &) | |
Construct from Istream. More... | |
bool | clean () |
Cleanup file name. More... | |
fileName | clean () const |
Cleanup file name. More... | |
fileType | type (const bool checkVariants=true, const bool followLink=true) const |
Return the file type: file, directory, undefined or. More... | |
bool | isName () const |
Return true if file name is a name without a path. More... | |
bool | hasPath () const |
Return true if file name has a path. More... | |
bool | isAbsolute () const |
Return true if file name is absolute. More... | |
fileName & | toAbsolute () |
Convert from relative to absolute. More... | |
word | name () const |
Return file name (part beyond last /) More... | |
string | caseName () const |
Return file name (part beyond last /), substitute for FOAM_CASE. More... | |
word | name (const bool noExt) const |
Return file name, optionally without extension. More... | |
fileName | path () const |
Return directory path name (part before last /) More... | |
fileName | lessExt () const |
Return file name without extension (part before last .) More... | |
word | ext () const |
Return file name extension (part after last .) More... | |
wordList | components (const char delimiter='/') const |
Return path components as wordList. More... | |
word | component (const size_type, const char delimiter='/') const |
Return a single component of the path. More... | |
void | operator= (const fileName &) |
void | operator= (fileName &&) |
void | operator= (const word &) |
void | operator= (const string &) |
void | operator= (const std::string &) |
void | operator= (const char *) |
Public Member Functions inherited from string | |
string () | |
Construct null. More... | |
string (const std::string &) | |
Construct from std::string. More... | |
string (const string &) | |
Copy constructor. More... | |
string (string &&) | |
Move constructor. More... | |
string (const char *) | |
Construct as copy of character array. More... | |
string (const UList< char > &) | |
Construct as copy of UList of character. More... | |
string (const char *, const size_type) | |
Construct as copy of specified number of characters. More... | |
string (const char) | |
Construct from a single character. More... | |
string (const size_type, const char) | |
Construct from copies of a single character. More... | |
string (Istream &) | |
Construct from Istream. More... | |
size_type | count (const char) const |
Count and return the number of a given character in the string. More... | |
bool | match (const std::string &) const |
True when strings match literally. More... | |
string & | replace (const string &oldStr, const string &newStr, size_type start=0) |
In this string replace first occurrence of sub-string oldStr. More... | |
string | replace (const string &oldStr, const string &newStr, size_type start=0) const |
Replace first occurrence of sub-string oldStr with newStr. More... | |
string & | replaceAll (const string &oldStr, const string &newStr, size_type start=0) |
In this string replace all occurrences of sub-string oldStr. More... | |
string | replaceAll (const string &oldStr, const string &newStr, size_type start=0) const |
Replace all occurrences of sub-string oldStr with newStr. More... | |
string & | expand (const bool allowEmpty=false) |
Expand initial tildes and all occurrences of environment variables. More... | |
bool | removeRepeated (const char) |
Remove repeated characters returning true if string changed. More... | |
string | removeRepeated (const char) const |
Return string with repeated characters removed. More... | |
bool | removeTrailing (const char) |
Remove trailing character returning true if string changed. More... | |
string | removeTrailing (const char) const |
Return string with trailing character removed. More... | |
bool | removeTrailing (const string &) |
Remove trailing string returning true if string changed. More... | |
string | removeTrailing (const string &) const |
Return string with trailing string removed. More... | |
void | strip (const string &) |
Strip characters from the start and end of the string. More... | |
string | operator() (const size_type i, const size_type n) const |
Return the sub-string from the i-th character for n characters. More... | |
string | operator() (const size_type n) const |
Return the sub-string from the first character for n characters. More... | |
void | operator= (const string &) |
void | operator= (string &&) |
template<class String > | |
Foam::string | quotemeta (const string &str, const char quote) |
Static Public Member Functions | |
static bool | valid (char) |
Is this character valid for a fileName? More... | |
Static Public Member Functions inherited from string | |
template<class String > | |
static bool | valid (const string &) |
Is this string type valid? More... | |
template<class String > | |
static bool | meta (const string &, const char quote='\\') |
Does this string have particular meta-characters? More... | |
template<class String > | |
static bool | stripInvalid (string &) |
Strip invalid characters from the given string. More... | |
template<class String > | |
static String | validate (const string &) |
Return a valid String from the given string. More... | |
template<class String > | |
static string | quotemeta (const string &, const char quote='\\') |
Return a String with quoted meta-characters from the given string. More... | |
Static Public Attributes | |
static const char *const | typeName = "fileName" |
static int | debug |
static const fileName | null |
An empty fileName. More... | |
Static Public Attributes inherited from string | |
static const char *const | typeName = "string" |
static int | debug |
static const string | null |
An empty string. More... | |
Friends | |
Istream & | operator>> (Istream &, fileName &) |
Ostream & | operator<< (Ostream &, const fileName &) |
A class for handling file names.
A fileName is a string of characters without whitespace or quotes. A fileName can be
The string::expand() method expands environment variables, etc,
Definition at line 79 of file fileName.H.
|
inline |
Construct null.
Definition at line 52 of file fileNameI.H.
Referenced by Foam::operator/().
Copy constructor.
Definition at line 58 of file fileNameI.H.
Move constructor.
Definition at line 64 of file fileNameI.H.
Copy constructor of word.
Definition at line 70 of file fileNameI.H.
Copy constructor of string.
Definition at line 76 of file fileNameI.H.
|
inline |
Copy constructor of std::string.
Definition at line 84 of file fileNameI.H.
|
inline |
Copy constructor of character array.
Definition at line 92 of file fileNameI.H.
Construct by concatenating elements of wordList separated by '/'.
Definition at line 40 of file fileName.C.
References forAll, fileName::operator=(), and fileName::type().
Construct from Istream.
Definition at line 31 of file fileNameIO.C.
|
inlinestatic |
Is this character valid for a fileName?
Definition at line 102 of file fileNameI.H.
References Foam::isspace().
bool clean | ( | ) |
Cleanup file name.
Removes repeated slashes /abc////def –> /abc/def
Removes '/./' /abc/def/./ghi/. –> /abc/def/./ghi abc/def/./ –> abc/def
Removes '/../' /abc/def/../ghi/jkl/nmo/.. –> /abc/ghi/jkl abc/../def/ghi/../jkl –> abc/../def/jkl
Removes trailing '/'
Definition at line 93 of file fileName.C.
References Foam::constant::universal::c, Foam::constant::physicoChemical::c1, and resize().
Referenced by fileName::clean(), argList::hasArgs(), and fileName::toAbsolute().
Foam::fileName clean | ( | ) | const |
Cleanup file name.
eg, remove repeated slashes, etc.
Definition at line 187 of file fileName.C.
References fileName::clean().
Foam::fileType type | ( | const bool | checkVariants = true , |
const bool | followLink = true |
||
) | const |
Return the file type: file, directory, undefined or.
link (only if followLink=false)
Definition at line 52 of file fileName.C.
References Foam::type().
Referenced by Foam::cp(), fileName::fileName(), Foam::mv(), and Foam::rmDir().
bool isName | ( | ) | const |
Return true if file name is a name without a path.
i.e. does not contain a '/'
Definition at line 61 of file fileName.C.
Referenced by Foam::systemDictIO().
bool hasPath | ( | ) | const |
bool isAbsolute | ( | ) | const |
Return true if file name is absolute.
Definition at line 73 of file fileName.C.
Referenced by IOobject::fileNameComponents(), masterUncollatedFileOperation::filePathInfo(), argList::hasArgs(), includeEntry::includeFileName(), Foam::ln(), Foam::systemDictIO(), fileName::toAbsolute(), collatedFileOperation::writeObject(), and triSurfaceMesh::writeObject().
Foam::fileName & toAbsolute | ( | ) |
Convert from relative to absolute.
Definition at line 79 of file fileName.C.
References fileName::clean(), Foam::cwd(), f(), and fileName::isAbsolute().
Foam::word name | ( | ) | const |
Return file name (part beyond last /)
Behaviour compared to /usr/bin/basename: Input name() basename ----- ------ -------- "foo" "foo" "foo" "/foo" "foo" "foo" "foo/bar" "bar" "bar" "/foo/bar" "bar" "bar" "/foo/bar/" "" "bar"
Definition at line 195 of file fileName.C.
Referenced by fileMonitorWatcher::addWatch(), collatedFileOperation::appendObject(), argList::argList(), processorPolyPatch::calcGeometry(), timeVaryingMappedFixedValuePointPatchField< Type >::checkTable(), dynamicCode::copyOrCreateFiles(), Foam::cp(), dictionaryName::dictName(), argList::hasArgs(), dynamicCode::libraryBaseName(), timeVaryingMappedFvPatchField< Type >::map(), fvMeshAdder::MapDimFields(), fvMeshAdder::MapPointFields(), fvMeshAdder::MapSurfaceFields(), Foam::mv(), fileName::name(), probes::prepare(), fileOperation::processorsPath(), extendedEdgeMeshFormat::read(), edgeMeshFormat::read(), interpolationLookUpTable::tableName(), triSurface::triSurfInstance(), timeVaryingMappedFixedValuePointPatchField< Type >::updateCoeffs(), ensightSetWriter::write(), ensightSurfaceWriter::write(), OBJsurfaceFormat< Face >::write(), OBJedgeFormat::write(), layerAverage::write(), streamlines::write(), STARCDsurfaceFormatCore::writeCase(), and STARCDedgeFormat::writeCase().
Foam::string caseName | ( | ) | const |
Return file name (part beyond last /), substitute for FOAM_CASE.
Definition at line 210 of file fileName.C.
References Foam::getEnv(), string::replace(), and string::string().
Referenced by IOobject::caseName().
Foam::word name | ( | const bool | noExt | ) | const |
Return file name, optionally without extension.
Definition at line 229 of file fileName.C.
References Foam::dot(), and fileName::name().
Foam::fileName path | ( | ) | const |
Return directory path name (part before last /)
Behaviour compared to /usr/bin/dirname: input path() dirname ----- ------ ------- "foo" "." "." "/foo" "/" "foo" "foo/bar" "foo" "foo" "/foo/bar" "/foo" "/foo" "/foo/bar/" "/foo/bar/" "/foo"
Definition at line 265 of file fileName.C.
Referenced by fileMonitorWatcher::addWatch(), timeVaryingMappedFixedValuePointPatchField< Type >::checkTable(), dynamicCode::copyOrCreateFiles(), Foam::cp(), dynamicCode::createMakeFiles(), dynamicCode::createMakeOptions(), includeEntry::execute(), argList::hasArgs(), Foam::mkDir(), fileOperation::processorsPath(), extendedEdgeMeshFormat::read(), edgeMeshFormat::read(), dynamicCode::writeDigest(), triSurfaceMesh::writeObject(), fileOperation::writeObject(), and distributedTriSurfaceMesh::writeObject().
Foam::fileName lessExt | ( | ) | const |
Return file name without extension (part before last .)
Definition at line 284 of file fileName.C.
Referenced by edgeMesh::canRead(), UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Foam::face >::canRead(), extendedEdgeMesh::canRead(), edgeMesh::New(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Foam::face >::New(), extendedEdgeMesh::New(), STARCDsurfaceFormat< Face >::read(), STARCDedgeFormat::read(), edgeMesh::read(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Foam::face >::read(), extendedEdgeMesh::read(), Foam::readDir(), triSurface::triSurfInstance(), OBJsurfaceFormat< Face >::write(), OBJedgeFormat::write(), STARCDsurfaceFormat< Face >::write(), STARCDedgeFormat::write(), STARCDsurfaceFormatCore::writeCase(), and STARCDedgeFormat::writeCase().
Foam::word ext | ( | ) | const |
Return file name extension (part after last .)
Definition at line 299 of file fileName.C.
References word::null.
Referenced by edgeMesh::canRead(), UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Foam::face >::canRead(), extendedEdgeMesh::canRead(), MeshedSurfaceProxy< Face >::canWriteType(), edgeMesh::New(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Foam::face >::New(), extendedEdgeMesh::New(), Foam::printSourceFileAndLine(), edgeMesh::read(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Foam::face >::read(), extendedEdgeMesh::read(), Foam::readDir(), triSurface::triSurface(), triSurface::triSurfInstance(), STLsurfaceFormat< Face >::write(), edgeMesh::write(), UnsortedMeshedSurface< Face >::write(), MeshedSurface< Foam::face >::write(), and triSurface::write().
Foam::wordList components | ( | const char | delimiter = '/' | ) | const |
Return path components as wordList.
Behaviour: Input components() ----- ------ "foo" 1("foo") "/foo" 1("foo") "foo/bar" 2("foo", "bar") "/foo/bar" 2("foo", "bar") "/foo/bar/" 2("foo", "bar")
Definition at line 314 of file fileName.C.
References DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), and fileName::component().
Referenced by fileName::component(), and Foam::cp().
Foam::word component | ( | const size_type | cmpt, |
const char | delimiter = '/' |
||
) | const |
Return a single component of the path.
Definition at line 342 of file fileName.C.
References fileName::components().
Referenced by fileName::components(), and Foam::cp().
void operator= | ( | const fileName & | str | ) |
Definition at line 353 of file fileName.C.
References string::operator=().
Referenced by fileName::fileName().
void operator= | ( | fileName && | str | ) |
Definition at line 359 of file fileName.C.
References string::operator=().
void operator= | ( | const word & | str | ) |
Definition at line 365 of file fileName.C.
References string::operator=().
void operator= | ( | const string & | str | ) |
Definition at line 371 of file fileName.C.
References string::operator=().
void operator= | ( | const std::string & | str | ) |
Definition at line 378 of file fileName.C.
References string::operator=().
void operator= | ( | const char * | str | ) |
Definition at line 385 of file fileName.C.
References string::operator=().
|
static |
Definition at line 93 of file fileName.H.
|
static |
Definition at line 94 of file fileName.H.
|
static |
An empty fileName.
Definition at line 97 of file fileName.H.
Referenced by dlLibraryTable::close(), Foam::cwd(), Time::dbDir(), dictionary::dictionary(), argList::displayDoc(), fileOperation::filePath(), masterUncollatedFileOperation::filePathInfo(), functionObjectList::findDict(), Foam::home(), meshWriter::noBoundary(), masterUncollatedFileOperation::fileOrNullOp::operator()(), fileOperation::processorsPath(), profileModel::readFromFile(), bladeModel::readFromFile(), functionObjectList::readFunctionObject(), masterUncollatedFileOperation::relativeObjectPath(), and Foam::search().