fileName Class Reference

A class for handling file names. More...

Inheritance diagram for fileName:
Collaboration diagram for fileName:

Public Types

enum  Type {
  UNDEFINED = 0, FILE = 1, DIRECTORY = 2, SYMLINK = 4,
  LINK = SYMLINK
}
 Enumerations to handle directory entry types. More...
 

Public Member Functions

 fileName ()=default
 Default construct. More...
 
 fileName (const fileName &)=default
 Copy construct. More...
 
 fileName (fileName &&)=default
 Move construct. More...
 
 fileName (const word &s)
 Copy construct from word. More...
 
 fileName (word &&s)
 Move construct from word. More...
 
 fileName (const string &s, bool doStrip=true)
 Copy construct from string. More...
 
 fileName (string &&s, bool doStrip=true)
 Move construct from string. More...
 
 fileName (const std::string &s, bool doStrip=true)
 Copy construct from std::string. More...
 
 fileName (std::string &&s, bool doStrip=true)
 Move construct from std::string. More...
 
 fileName (const char *s, bool doStrip=true)
 Copy construct from character array. More...
 
 fileName (const UList< word > &list)
 Construct by concatenating elements of wordList separated by '/'. More...
 
 fileName (std::initializer_list< word > list)
 Construct by concatenating words separated by '/'. More...
 
 fileName (Istream &is)
 Construct from Istream. More...
 
bool assign (const token &tok)
 Assign from word or string token. More...
 
void stripInvalid ()
 Strip invalid characters. More...
 
bool clean ()
 Cleanup filename (inplace) More...
 
Type type (bool followLink=true, bool checkGzip=false) const
 Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK). More...
 
bool isAbsolute () const
 Return true if filename is absolute, which means it starts with a '/' or '\' or (windows-only) with a filesystem-root. More...
 
fileNametoAbsolute ()
 Convert from relative to absolute. More...
 
bool isBackup () const
 Return true if file name ends with "~", ".bak", ".old", ".save". More...
 
fileName path () const
 Return directory path name (part before last /) More...
 
bool has_path () const
 True if it contains a '/' character. More...
 
word name () const
 Return basename (part beyond last /), including its extension. More...
 
fileNamereplace_name (const word &newName)
 Replace basename (part beyond last /) with a new name. More...
 
word stem () const
 Return basename, without extension. More...
 
word ext () const
 Return file name extension (part after last .) More...
 
fileNameext (const word &ending)
 Append a '.' and the ending, and return the object. More...
 
fileNamereplace_ext (const word &ending)
 Remove extension (if any) and append a new one. More...
 
fileName lessExt () const
 Return file name without extension (part before last .) More...
 
fileName relative (const fileName &parent, const bool caseTag=false) const
 Return a relative name by stripping off the parent directory where possible. More...
 
wordList components (const char delim='/') const
 Return path components as wordList. More...
 
word component (const size_type cmpt, const char delim='/') const
 Return a single component of the path or empty if out of range. More...
 
fileNameoperator= (const fileName &str)
 Copy assignment, no character validation required. More...
 
fileNameoperator= (fileName &&str)
 Move assignment, no character validation required. More...
 
fileNameoperator= (const word &str)
 Copy assignment, no character validation required. More...
 
fileNameoperator= (word &&str)
 Move assignment, no character validation required. More...
 
fileNameoperator= (const string &str)
 Copy assignment, stripping invalid characters. More...
 
fileNameoperator= (string &&str)
 Move assignment, stripping invalid characters. More...
 
fileNameoperator= (const std::string &str)
 Copy assignment, stripping invalid characters. More...
 
fileNameoperator= (std::string &&str)
 Move assignment, stripping invalid characters. More...
 
fileNameoperator= (const char *str)
 Copy, stripping invalid characters. More...
 
fileNameoperator/= (const string &other)
 Append a path element with '/' separator. More...
 
bool hasPath () const
 Same as has_path() More...
 
bool removePath ()
 Same as remove_path() More...
 
bool hasExt () const
 Same as has_ext() More...
 
bool hasExt (const std::string &s) const
 Same as has_ext() More...
 
bool removeExt ()
 Same as remove_ext() More...
 
word nameLessExt () const
 Same as stem() More...
 
word name (const bool noExt) const
 Deprecated(2017-03) return basename, optionally without extension. More...
 
bool remove_path ()
 Remove leading path, return true if string changed. More...
 
bool remove_ext ()
 Remove extension, returning true if string changed. More...
 
bool has_ext () const
 Various checks for extensions. More...
 
bool has_ext (const char *ending) const
 Various checks for extensions. More...
 
bool has_ext (const std::string &ending) const
 Various checks for extensions. More...
 
bool has_ext (const wordRe &ending) const
 Various checks for extensions. More...
 
- Public Member Functions inherited from string
 string ()=default
 Default construct. More...
 
 string (const std::string &str)
 Copy construct from std::string. More...
 
 string (std::string &&str)
 Move construct from std::string. More...
 
 string (const char *str)
 Construct as copy of character array. More...
 
 string (const char *str, const size_type len)
 Construct as copy with a maximum number of characters. More...
 
 string (const char c)
 Construct from a single character. More...
 
 string (const size_type len, const char c)
 Construct fill copies of a single character. More...
 
 string (Istream &is)
 Construct from Istream. More...
 
bool match (const std::string &text) const
 Test for equality. More...
 
stringreplace (const std::string &s1, const std::string &s2, size_type pos=0)
 Replace first occurrence of sub-string s1 with s2, beginning at pos. More...
 
stringreplaceAll (const std::string &s1, const std::string &s2, size_type pos=0)
 Replace all occurrences of sub-string s1 with s2, beginning at pos in the string. More...
 
stringreplaceAny (const std::string &s1, const char c2, size_type pos=0)
 Replace any occurrence of s1 characters with c2, beginning at pos in the string. More...
 
stringexpand (const bool allowEmpty=false)
 Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::expand. More...
 
bool removeRepeated (const char character)
 Remove repeated characters. More...
 
bool removeStart (const std::string &text)
 Remove the given text from the start of the string. More...
 
bool removeStart (const char c)
 Remove leading character, unless string is a single character. More...
 
bool removeEnd (const std::string &text)
 Remove the given text from the end of the string. More...
 
bool removeEnd (const char c)
 Remove trailing character, unless string is a single character. More...
 
void swap (std::string &str)
 Swap contents. Self-swapping is a no-op. More...
 
bool operator() (const std::string &text) const
 Test for equality. Allows use as a predicate. More...
 
bool contains (char c) const noexcept
 True if string contains given character (cf. C++23) More...
 
bool contains (const std::string &s) const noexcept
 True if string contains given [string view] substring (cf. C++23) More...
 
bool contains (const char *s) const
 True if string contains given substring (cf. C++23) More...
 
bool starts_with (char c) const
 True if string starts with given character (cf. C++20) More...
 
bool starts_with (const std::string &s) const
 True if string starts with given [string view] prefix (C++20) More...
 
bool starts_with (const char *s) const
 True if string starts with given prefix (C++20) More...
 
bool ends_with (char c) const
 True if string ends with given character (cf. C++20) More...
 
bool ends_with (const std::string &s) const
 True if string ends with given [string view] suffix (cf. C++20) More...
 
bool ends_with (const char *s) const
 True if string ends with given suffix (cf. C++20) More...
 
size_type count (const char c) const
 Count the number of occurrences of the specified character in the string. More...
 
bool startsWith (const std::string &s) const
 Deprecated(2019-11) More...
 
bool endsWith (const std::string &s) const
 Deprecated(2019-11) More...
 
bool removeTrailing (const char c)
 Deprecated(2019-11) More...
 

Static Public Member Functions

static bool valid (char c)
 Is this character valid for a fileName? More...
 
static fileName validate (const std::string &, const bool doClean=true)
 Construct fileName without invalid characters, possibly applying other transformations such as changing the path separator, removing duplicate or trailing slashes, etc. More...
 
static fileName concat (const std::string &s1, const std::string &s2, const char delim='/')
 Join two strings with a path separator ('/' by default). More...
 
static bool equals (const std::string &s1, const std::string &s2)
 This is a specialized (possibly slower) version of compare() that ignores duplicate or trailing slashes. More...
 
static bool clean (std::string &str)
 Cleanup filename string, possibly applies other transformations such as changing the path separator etc. More...
 
static bool isAbsolute (const std::string &str)
 Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root. More...
 
static bool isBackup (const std::string &str)
 Return true if string ends with "~", ".bak", ".old", ".save". More...
 
static std::string path (const std::string &str)
 Return directory path name (part before last /) More...
 
static std::string name (const std::string &str)
 Return basename (part beyond last /), including its extension. More...
 
static std::string stem (const std::string &str)
 Return the basename, without extension. More...
 
static std::string nameLessExt (const std::string &s)
 Same as stem() More...
 
- Static Public Member Functions inherited from string
static std::string::size_type length (const char *s)
 Length of the character sequence (with nullptr protection) More...
 
static std::string::size_type length (const std::string &s)
 The length of the string. More...
 
template<class StringType >
static bool valid (const std::string &str)
 Does the string contain valid characters only? More...
 
template<class StringType >
static bool stripInvalid (std::string &str)
 Strip invalid characters from the given string. More...
 
template<class StringType >
static StringType validate (const std::string &str)
 Return a valid String from the given string. More...
 

Static Public Attributes

static const char *const typeName = "fileName"
 The typeName. More...
 
static int debug
 Debugging. More...
 
static int allowSpaceInFileName
 Allow space character in fileName. To be used with caution. More...
 
static const fileName null
 An empty fileName. More...
 
- Static Public Attributes inherited from string
static const char *const typeName = "string"
 The type name "string". More...
 
static int debug
 The debug flag. More...
 
static const string null
 An empty string. More...
 

Additional Inherited Members

- Protected Member Functions inherited from string
std::string::size_type find_ext () const
 Find position of a file extension dot, return npos on failure. More...
 
word ext () const
 Return file name extension (part after last .) More...
 
bool ext (const word &ending)
 Append a '.' and the ending. More...
 
bool has_ext () const
 Return true if it has an extension or simply ends with a '.'. More...
 
bool has_ext (const char *ending) const
 Return true if the extension is the same as the given ending. More...
 
bool has_ext (const std::string &ending) const
 Return true if the extension is the same as the given ending. More...
 
bool has_ext (const wordRe &ending) const
 Return true if the extension matches the given ending. More...
 
bool remove_path ()
 Remove leading path, return true if string changed. More...
 
bool remove_ext ()
 Remove extension, return true if string changed. More...
 
- Static Protected Member Functions inherited from string
static std::string::size_type find_ext (const std::string &str)
 Find position of a file extension dot, return npos on failure. More...
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const char *fmt, const PrimitiveType &val)
 A printf-style formatter for a primitive. More...
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const std::string &fmt, const PrimitiveType &val)
 A printf-style formatter for a primitive. More...
 

Detailed Description

A class for handling file names.

A fileName is a string of characters without whitespace or quotes. A fileName can be

  • constructed from a char*, a string or a word
  • concatenated by adding a '/' separator
  • decomposed into the path, name or component list
  • interrogated for type and access mode

The string::expand() method expands environment variables, etc,

Source files

Definition at line 72 of file fileName.H.

Member Enumeration Documentation

◆ Type

enum Type

Enumerations to handle directory entry types.

Enumerator
UNDEFINED 

Undefined type.

FILE 

A regular file.

DIRECTORY 

A directory.

SYMLINK 

A symbolic link.

LINK 

Same as symlink.

Definition at line 81 of file fileName.H.

Constructor & Destructor Documentation

◆ fileName() [1/13]

fileName ( )
default

Default construct.

◆ fileName() [2/13]

fileName ( const fileName )
default

Copy construct.

◆ fileName() [3/13]

fileName ( fileName &&  )
default

Move construct.

◆ fileName() [4/13]

fileName ( const word s)
inline

Copy construct from word.

Definition at line 26 of file fileNameI.H.

◆ fileName() [5/13]

fileName ( word &&  s)
inline

Move construct from word.

Definition at line 32 of file fileNameI.H.

◆ fileName() [6/13]

fileName ( const string s,
bool  doStrip = true 
)
inline

Copy construct from string.

Definition at line 38 of file fileNameI.H.

References fileName::stripInvalid().

Here is the call graph for this function:

◆ fileName() [7/13]

fileName ( string &&  s,
bool  doStrip = true 
)
inline

Move construct from string.

Definition at line 49 of file fileNameI.H.

References fileName::stripInvalid().

Here is the call graph for this function:

◆ fileName() [8/13]

fileName ( const std::string &  s,
bool  doStrip = true 
)
inline

Copy construct from std::string.

Definition at line 60 of file fileNameI.H.

References fileName::stripInvalid().

Here is the call graph for this function:

◆ fileName() [9/13]

fileName ( std::string &&  s,
bool  doStrip = true 
)
inline

Move construct from std::string.

Definition at line 71 of file fileNameI.H.

References fileName::stripInvalid().

Here is the call graph for this function:

◆ fileName() [10/13]

fileName ( const char *  s,
bool  doStrip = true 
)
inline

Copy construct from character array.

Definition at line 82 of file fileNameI.H.

References fileName::stripInvalid().

Here is the call graph for this function:

◆ fileName() [11/13]

fileName ( const UList< word > &  list)
explicit

Construct by concatenating elements of wordList separated by '/'.

Definition at line 310 of file fileName.C.

References reserve().

Here is the call graph for this function:

◆ fileName() [12/13]

fileName ( std::initializer_list< word list)
explicit

Construct by concatenating words separated by '/'.

Definition at line 330 of file fileName.C.

References reserve().

Here is the call graph for this function:

◆ fileName() [13/13]

fileName ( Istream is)
explicit

Construct from Istream.

Definition at line 27 of file fileNameIO.C.

Member Function Documentation

◆ assign()

bool assign ( const token tok)

Assign from word or string token.

Returns
false if the token was the incorrect type

Definition at line 35 of file fileNameIO.C.

References Foam::FieldOps::assign(), token::isQuotedString(), token::isWord(), token::stringToken(), and token::wordToken().

Referenced by Foam::expandLeadingTag(), Foam::operator>>(), and fileName::replace_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valid()

bool valid ( char  c)
inlinestatic

Is this character valid for a fileName?

Definition at line 95 of file fileNameI.H.

References Foam::constant::universal::c, and Foam::isspace().

Referenced by FileName::valid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate()

Foam::fileName validate ( const std::string &  str,
const bool  doClean = true 
)
static

Construct fileName without invalid characters, possibly applying other transformations such as changing the path separator, removing duplicate or trailing slashes, etc.

Definition at line 199 of file fileName.C.

Referenced by Foam::argList::get< Foam::fileName >().

Here is the caller graph for this function:

◆ concat()

Foam::fileName concat ( const std::string &  s1,
const std::string &  s2,
const char  delim = '/' 
)
static

Join two strings with a path separator ('/' by default).

No separator is added if either argument is an empty string or if the arguments already had the path separator at the junction. Invalid characters are not stripped (ie, retained).

Definition at line 211 of file fileName.C.

References string::length().

Referenced by dictionary::add(), dictionary::changeKeyword(), dictionary::dictionary(), and primitiveEntry::primitiveEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

bool equals ( const std::string &  s1,
const std::string &  s2 
)
static

This is a specialized (possibly slower) version of compare() that ignores duplicate or trailing slashes.

Definition at line 238 of file fileName.C.

◆ stripInvalid()

void stripInvalid ( )
inline

Strip invalid characters.

Definition at line 106 of file fileNameI.H.

References Foam::ensightOutput::debug, Foam::endl(), and Foam::exit().

Referenced by fileName::fileName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean() [1/2]

bool clean ( std::string &  str)
static

Cleanup filename string, possibly applies other transformations such as changing the path separator etc.

Changes back-slash to forward-slash path separator, while preserving windows UNC:

*    \\server\abc\def  -->   \\server/abc/def
* 

Removes trailing slash:

*    /                 -->   /
*    /abc/             -->   /abc
* 

Removes repeated slashes, but preserves UNC:

*    /abc////def          -->   /abc/def
*    \\server\abc////def  -->   \\server/abc/def
* 

Removes "/./" (current directory), except for leading one:

*    /abc/def/./ghi/.   -->   /abc/def/ghi
*    abc/def/./         -->   abc/def
*    ./abc/             -->   ./abc
* 

Removes "/../" (parent directory), except for leading one:

*    /abc/def/../ghi/jkl/nmo/..   -->   /abc/ghi/jkl
*    abc/../def/ghi/../jkl        -->   abc/../def/jkl
* 
Returns
True if the content changed

Definition at line 192 of file fileName.C.

Referenced by dictionary::cfindScopedDict(), externalFileCoupler::externalFileCoupler(), IOobject::fileNameComponents(), averageNeighbourFvGeometryScheme::movePoints(), argList::parse(), abort::read(), MapFieldConstraint< Type >::read(), shortestPathSet::shortestPathSet(), and mappedPatchBase::subRegistry().

Here is the caller graph for this function:

◆ clean() [2/2]

bool clean ( )

Cleanup filename (inplace)

Returns
True if the content changed

Definition at line 385 of file fileName.C.

Referenced by dictionary::makeScopedDict(), and entry::New().

Here is the caller graph for this function:

◆ type()

Foam::fileName::Type type ( bool  followLink = true,
bool  checkGzip = false 
) const

Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK).

Parameters
followLinkwhen false it will return SYMLINK for a symlink rather than following it.
checkGzipadd an additional test for a gzip FILE

Definition at line 353 of file fileName.C.

Referenced by Foam::broadcastFile_recursive(), Foam::cp(), Foam::mv(), and fvMeshDistribute::printFieldInfo().

Here is the caller graph for this function:

◆ isAbsolute() [1/2]

bool isAbsolute ( const std::string &  str)
inlinestatic

Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.

Definition at line 129 of file fileNameI.H.

Referenced by pointNoise::calculate(), surfaceNoise::calculate(), chemkinReader::chemkinReader(), Foam::ln(), loadLibrary(), argList::parse(), abort::read(), surfaceFormatsCore::relativeFilePath(), includeEtcEntry::resolveEtcFile(), includeEntry::resolveFile(), collatedFileOperation::writeObject(), and triSurfaceMesh::writeObject().

Here is the caller graph for this function:

◆ isAbsolute() [2/2]

bool isAbsolute ( ) const
inline

Return true if filename is absolute, which means it starts with a '/' or '\' or (windows-only) with a filesystem-root.

Definition at line 151 of file fileNameI.H.

◆ toAbsolute()

Foam::fileName & toAbsolute ( )

Convert from relative to absolute.

As a side-effect, always performs a clean() to remove "/./" etc

Definition at line 370 of file fileName.C.

References Foam::cwd(), and f().

Referenced by Time::NewGlobalTime(), boundaryDataSurfaceReader::readField(), and boundaryDataSurfaceReader::readPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBackup() [1/2]

bool isBackup ( const std::string &  str)
static

Return true if string ends with "~", ".bak", ".old", ".save".

Definition at line 279 of file fileName.C.

References Foam::dot(), and s.

Here is the call graph for this function:

◆ isBackup() [2/2]

bool isBackup ( ) const
inline

Return true if file name ends with "~", ".bak", ".old", ".save".

Definition at line 157 of file fileNameI.H.

◆ path() [1/2]

std::string path ( const std::string &  str)
inlinestatic

Return directory path name (part before last /)

The result normally corresponds to a Foam::fileName

Behaviour compared to /usr/bin/dirname:

*   input           path()          dirname
*   -----           ------          -------
*   ""              "."             "."
*   "abc"           "."             "."
*   "/"             "/"             "/"
*   "/abc"          "/"             "/"
*   "abc/def"       "abc"           "abc"
*   "/abc/def"      "/abc"          "/abc"
*   "/abc/def/"     "/abc/def"      "/abc"
*   "/abc/../def"   "/abc/.."       "/abc/.."
* 

Definition at line 169 of file fileNameI.H.

Referenced by fileMonitorWatcher::addWatch(), Foam::broadcastFile_single(), chemkinReader::chemkinReader(), dynamicCode::copyOrCreateFiles(), Foam::cp(), dynamicCode::createMakeFiles(), dynamicCode::createMakeOptions(), includeEntry::execute(), coordSetWriter::getExpectedPath(), coordSetWriter::getFieldPrefixedPath(), isoSurfacePoint::isoSurfacePoint(), seriesWriter::load(), Foam::mkDir(), Time::New(), Time::NewGlobalTime(), sceneWriter::open(), fileOperation::processorsPath(), surfMesh::removeFiles(), polyMesh::removeFiles(), faMesh::removeFiles(), seriesWriter::scan(), seriesWriter::write(), proxyWriter::write(), scene::write(), x3dWriter::write(), starcdWriter::write(), foamWriter::write(), rawWriter::write(), abaqusWriter::write(), vtkWriter::write(), nastranWriter::write(), vtmWriter::write(), rawWriter::writeBuffered(), csvWriter::writeBuffered(), gnuplotWriter::writeBuffered(), ensightWriter::writeCollated(), dynamicCode::writeDigest(), isoAdvection::writeIsoFaces(), triSurfaceMesh::writeObject(), distributedTriSurfaceMesh::writeObject(), Foam::vtk::writePointSet(), gnuplotWriter::writeTemplate(), csvWriter::writeTemplate(), rawWriter::writeTemplate(), foamWriter::writeTemplate(), xmgraceWriter::writeTemplate(), starcdWriter::writeTemplate(), nastranWriter::writeTemplate(), boundaryDataWriter::writeTemplate(), abaqusWriter::writeTemplate(), x3dWriter::writeTemplate(), debugWriter::writeTemplate(), and ensightWriter::writeUncollated().

◆ path() [2/2]

Foam::fileName path ( ) const
inline

Return directory path name (part before last /)

Definition at line 186 of file fileNameI.H.

Referenced by entry::New().

Here is the caller graph for this function:

◆ has_path()

bool has_path ( ) const
inline

True if it contains a '/' character.

Definition at line 163 of file fileNameI.H.

Referenced by Foam::dlOpen(), and fileName::hasPath().

Here is the caller graph for this function:

◆ name() [1/3]

std::string name ( const std::string &  str)
inlinestatic

Return basename (part beyond last /), including its extension.

The result normally corresponds to a Foam::word

Behaviour compared to /usr/bin/basename:

*   input           name()          basename
*   -----           ------          --------
*   ""              ""              ""
*   "abc"           "abc"           "abc"
*   "/"             ""              "/"
*   "/abc"          "abc"           "abc"
*   "abc/def"       "def"           "def"
*   "/abc/def"      "def"           "def"
*   "/abc/def/"     ""              "def"
*   "/abc/../def"   "def"           "def"
* 

Definition at line 192 of file fileNameI.H.

Referenced by fileMonitorWatcher::addWatch(), seriesWriter::append(), argList::argList(), dynamicCode::copyOrCreateFiles(), Foam::cp(), isoSurfaceTopo::isoSurfaceTopo(), CloudSubModelBase< Foam::KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::localPath(), Foam::mv(), Time::New(), writeFile::newFile(), Time::NewGlobalTime(), processorPolyPatch::order(), fileOperation::processorsPath(), ensightCase::setTime(), triSurface::triSurfInstance(), abaqusWriter::write(), ensightWriter::writeCollated(), and nastranWriter::writeTemplate().

Here is the caller graph for this function:

◆ name() [2/3]

Foam::word name ( ) const
inline

Return basename (part beyond last /), including its extension.

Definition at line 205 of file fileNameI.H.

Referenced by fileName::name(), entry::New(), and scene::write().

Here is the caller graph for this function:

◆ replace_name()

Foam::fileName & replace_name ( const word newName)

Replace basename (part beyond last /) with a new name.

Definition at line 419 of file fileName.C.

References fileName::assign(), and string::length().

Here is the call graph for this function:

◆ stem() [1/2]

std::string stem ( const std::string &  str)
static

Return the basename, without extension.

The result normally corresponds to a Foam::word

Definition at line 391 of file fileName.C.

References Foam::dot().

Referenced by dlLibraryTable::basename(), surfaceNoise::calculate(), seriesWriter::print(), seriesWriter::scan(), gnuplotWriter::writeBuffered(), gnuplotWriter::writeTemplate(), and nastranWriter::writeTemplate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stem() [2/2]

Foam::word stem ( ) const
inline

Return basename, without extension.

Definition at line 217 of file fileNameI.H.

Referenced by vtmWriter::append(), fileName::name(), and fileName::nameLessExt().

Here is the caller graph for this function:

◆ ext() [1/2]

◆ ext() [2/2]

Foam::fileName & ext ( const word ending)
inline

Append a '.' and the ending, and return the object.

The '.' and ending will not be added when the ending is empty, or when the file name is empty or ended with a '/'.

Definition at line 223 of file fileNameI.H.

References string::ext().

Here is the call graph for this function:

◆ replace_ext()

Foam::fileName & replace_ext ( const word ending)
inline

Remove extension (if any) and append a new one.

Definition at line 230 of file fileNameI.H.

References string::ext(), and string::remove_ext().

Referenced by Foam::dlOpen(), sceneWriter::open(), and scene::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lessExt()

Foam::fileName lessExt ( ) const
inline

Return file name without extension (part before last .)

Definition at line 238 of file fileNameI.H.

Referenced by STARCDsurfaceFormat< Face >::read(), STARCDedgeFormat::read(), STARCDsurfaceFormat< Face >::write(), STARCDedgeFormat::write(), Foam::vtk::writePointSet(), and abaqusWriter::writeTemplate().

Here is the caller graph for this function:

◆ relative()

Foam::fileName relative ( const fileName parent,
const bool  caseTag = false 
) const

Return a relative name by stripping off the parent directory where possible.

Parameters
parentthe parent directory
caseTagreplace the parent with <case> for later use with expand(), or prefix <case> if the file name was not an absolute location

Definition at line 443 of file fileName.C.

References f(), UList< T >::find(), and string::length().

Here is the call graph for this function:

◆ components()

Foam::wordList components ( const char  delim = '/') const

Return path components as wordList.

Behaviour:

*   input           components()
*   -----           ------------
*   ""              ()
*   "."             (".")
*   "abc"           ("abc")
*   "/abc"          ("abc")
*   "abc/def"       ("abc", "def")
*   "/abc/def"      ("abc", "def")
*   "/abc/def/"     ("abc", "def")
* 

Definition at line 532 of file fileName.C.

Referenced by mappedPatchBase::subRegistry().

Here is the caller graph for this function:

◆ component()

Foam::word component ( const size_type  cmpt,
const char  delim = '/' 
) const

Return a single component of the path or empty if out of range.

The location npos returns the last component

Definition at line 552 of file fileName.C.

◆ operator=() [1/9]

Foam::fileName & operator= ( const fileName str)
inline

Copy assignment, no character validation required.

Self-assignment is a no-op.

Definition at line 253 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [2/9]

Foam::fileName & operator= ( fileName &&  str)
inline

Move assignment, no character validation required.

Self-assignment is a no-op.

Definition at line 264 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [3/9]

Foam::fileName & operator= ( const word str)
inline

Copy assignment, no character validation required.

Definition at line 275 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [4/9]

Foam::fileName & operator= ( word &&  str)
inline

Move assignment, no character validation required.

Definition at line 282 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [5/9]

Foam::fileName & operator= ( const string str)
inline

Copy assignment, stripping invalid characters.

Definition at line 289 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [6/9]

Foam::fileName & operator= ( string &&  str)
inline

Move assignment, stripping invalid characters.

Definition at line 297 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [7/9]

Foam::fileName & operator= ( const std::string &  str)
inline

Copy assignment, stripping invalid characters.

Definition at line 305 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [8/9]

Foam::fileName & operator= ( std::string &&  str)
inline

Move assignment, stripping invalid characters.

Definition at line 313 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [9/9]

Foam::fileName & operator= ( const char *  str)
inline

Copy, stripping invalid characters.

Definition at line 321 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator/=()

Foam::fileName & operator/= ( const string other)

Append a path element with '/' separator.

No '/' separator is added if this or the argument are empty.

Definition at line 577 of file fileName.C.

References s.

◆ hasPath()

bool hasPath ( ) const
inline

Same as has_path()

Definition at line 556 of file fileName.H.

References fileName::has_path().

Here is the call graph for this function:

◆ removePath()

bool removePath ( )
inline

Same as remove_path()

Definition at line 561 of file fileName.H.

References string::remove_path().

Here is the call graph for this function:

◆ hasExt() [1/2]

bool hasExt ( ) const
inline

Same as has_ext()

Definition at line 566 of file fileName.H.

References string::has_ext().

Here is the call graph for this function:

◆ hasExt() [2/2]

bool hasExt ( const std::string &  s) const
inline

Same as has_ext()

Definition at line 571 of file fileName.H.

References string::has_ext(), and s.

Here is the call graph for this function:

◆ removeExt()

bool removeExt ( )
inline

Same as remove_ext()

Definition at line 576 of file fileName.H.

References string::remove_ext().

Here is the call graph for this function:

◆ nameLessExt() [1/2]

static std::string nameLessExt ( const std::string &  s)
inlinestatic

Same as stem()

Definition at line 581 of file fileName.H.

References s, and fileName::stem().

Here is the call graph for this function:

◆ nameLessExt() [2/2]

word nameLessExt ( ) const
inline

Same as stem()

Definition at line 589 of file fileName.H.

References fileName::stem().

Here is the call graph for this function:

◆ name() [3/3]

word name ( const bool  noExt) const
inline

Deprecated(2017-03) return basename, optionally without extension.

Deprecated:
(2017-03) - use name() or stem() methods which describe their behaviour explicitly

Definition at line 597 of file fileName.H.

References fileName::name(), and fileName::stem().

Here is the call graph for this function:

◆ remove_path()

bool remove_path
inline

Remove leading path, return true if string changed.

Definition at line 79 of file stringI.H.

Referenced by seriesWriter::append().

Here is the caller graph for this function:

◆ remove_ext()

bool remove_ext
inline

Remove extension, returning true if string changed.

Definition at line 93 of file stringI.H.

Referenced by fileWriter::open(), seriesWriter::scan(), and FIREMeshWriter::write().

Here is the caller graph for this function:

◆ has_ext() [1/4]

bool has_ext
inline

Various checks for extensions.

Definition at line 43 of file stringI.H.

Referenced by vtmWriter::append(), Foam::dlOpen(), STLCore::isBinaryName(), seriesWriter::load(), seriesWriter::scan(), seriesWriter::write(), vtmWriter::write(), Foam::vtk::writePointSet(), and NURBS3DSurface::writeVTK().

Here is the caller graph for this function:

◆ has_ext() [2/4]

bool has_ext
inline

Various checks for extensions.

Definition at line 49 of file stringI.H.

◆ has_ext() [3/4]

bool has_ext
inline

Various checks for extensions.

Definition at line 64 of file stringI.H.

◆ has_ext() [4/4]

bool has_ext

Various checks for extensions.

Definition at line 74 of file string.C.

Member Data Documentation

◆ typeName

const char *const typeName = "fileName"
static

The typeName.

Definition at line 96 of file fileName.H.

◆ debug

int debug
static

Debugging.

Definition at line 101 of file fileName.H.

◆ allowSpaceInFileName

int allowSpaceInFileName
static

Allow space character in fileName. To be used with caution.

Definition at line 106 of file fileName.H.

◆ null


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