Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
fileName Class Reference

A class for handling file names. More...

Inheritance diagram for fileName:
Inheritance graph
[legend]
Collaboration diagram for fileName:
Collaboration graph
[legend]

Public Types

enum  Type { UNDEFINED = 0, FILE = 1, DIRECTORY = 2, LINK = 4 }
 

Public Member Functions

 fileName ()=default
 
 fileName (const fileName &)=default
 
 fileName (fileName &&)=default
 
 fileName (const word &s)
 
 fileName (word &&s)
 
 fileName (const string &s, bool doStrip=true)
 
 fileName (string &&s, bool doStrip=true)
 
 fileName (const std::string &s, bool doStrip=true)
 
 fileName (std::string &&s, bool doStrip=true)
 
 fileName (const char *s, bool doStrip=true)
 
 fileName (const UList< word > &list)
 
 fileName (std::initializer_list< word > list)
 
 fileName (Istream &is)
 
bool assign (const token &tok)
 
void stripInvalid ()
 
bool clean ()
 
Type type (bool followLink=true, bool checkGzip=false) const
 
bool isAbsolute () const
 
fileNametoAbsolute ()
 
bool isBackup () const
 
word name () const
 
word nameLessExt () const
 
word name (const bool noExt) const
 
fileName path () const
 
bool hasPath () const
 
bool removePath ()
 
fileName relative (const fileName &parent, const bool caseTag=false) const
 
fileName lessExt () const
 
word ext () const
 
fileNameext (const word &ending)
 
wordList components (const char delim='/') const
 
word component (const size_type cmpt, const char delim='/') const
 
fileNameoperator= (const fileName &str)
 
fileNameoperator= (fileName &&str)
 
fileNameoperator= (const word &str)
 
fileNameoperator= (word &&str)
 
fileNameoperator= (const string &str)
 
fileNameoperator= (string &&str)
 
fileNameoperator= (const std::string &str)
 
fileNameoperator= (std::string &&str)
 
fileNameoperator= (const char *str)
 
fileNameoperator/= (const string &other)
 
bool hasExt () const
 
bool hasExt (const char *ending) const
 
bool hasExt (const std::string &ending) const
 
bool hasExt (const wordRe &ending) const
 
bool removeExt ()
 
- Public Member Functions inherited from string
 string ()=default
 
 string (const std::string &str)
 
 string (std::string &&str)
 
 string (const char *str)
 
 string (const char *str, const size_type len)
 
 string (const char c)
 
 string (const size_type len, const char c)
 
 string (Istream &is)
 
bool match (const std::string &text) const
 
stringreplace (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAll (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAny (const std::string &s1, const char c2, size_type pos=0)
 
stringexpand (const bool allowEmpty=false)
 
bool removeRepeated (const char character)
 
bool removeStart (const std::string &text)
 
bool removeStart (const char c)
 
bool removeEnd (const std::string &text)
 
bool removeEnd (const char c)
 
void swap (std::string &str)
 
bool operator() (const std::string &text) const
 
bool starts_with (const std::string &s) const
 
bool starts_with (const char c) const
 
bool ends_with (const std::string &s) const
 
bool ends_with (const char c) const
 
size_type count (const char c) const
 
bool startsWith (const std::string &s) const
 
bool endsWith (const std::string &s) const
 
bool removeTrailing (const char c)
 

Static Public Member Functions

static bool valid (char c)
 
static fileName validate (const std::string &, const bool doClean=true)
 
static fileName concat (const std::string &s1, const std::string &s2, const char delim='/')
 
static bool equals (const std::string &s1, const std::string &s2)
 
static bool clean (std::string &str)
 
static bool isAbsolute (const std::string &str)
 
static bool isBackup (const std::string &str)
 
static std::string name (const std::string &str)
 
static std::string nameLessExt (const std::string &str)
 
static std::string path (const std::string &str)
 
- Static Public Member Functions inherited from string
template<class StringType >
static bool valid (const std::string &str)
 
template<class StringType >
static bool stripInvalid (std::string &str)
 
template<class StringType >
static StringType validate (const std::string &str)
 

Static Public Attributes

static const char *const typeName = "fileName"
 
static int debug
 
static int allowSpaceInFileName
 
static const fileName null
 
- Static Public Attributes inherited from string
static const char *const typeName = "string"
 
static int debug
 
static const string null
 

Additional Inherited Members

- Protected Member Functions inherited from string
std::string::size_type find_ext () const
 
word ext () const
 
bool ext (const word &ending)
 
bool hasPath () const
 
bool hasExt () const
 
bool hasExt (const char *ending) const
 
bool hasExt (const std::string &ending) const
 
bool hasExt (const wordRe &ending) const
 
bool removeExt ()
 
bool removePath ()
 
- Static Protected Member Functions inherited from string
static std::string::size_type find_ext (const std::string &str)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const char *fmt, const PrimitiveType &val)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const std::string &fmt, const PrimitiveType &val)
 

Detailed Description

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,

Source files

Definition at line 71 of file fileName.H.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
UNDEFINED 

Undefined type.

FILE 

A file.

DIRECTORY 

A directory.

LINK 

A symlink.

Definition at line 78 of file fileName.H.

Constructor & Destructor Documentation

◆ fileName() [1/13]

fileName ( )
default

◆ fileName() [2/13]

fileName ( const fileName )
default

◆ fileName() [3/13]

fileName ( fileName &&  )
default

◆ fileName() [4/13]

fileName ( const word s)
inline

Definition at line 26 of file fileNameI.H.

◆ fileName() [5/13]

fileName ( word &&  s)
inline

Definition at line 32 of file fileNameI.H.

◆ fileName() [6/13]

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

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

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

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

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

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

Definition at line 310 of file fileName.C.

◆ fileName() [12/13]

fileName ( std::initializer_list< word list)
explicit

Definition at line 330 of file fileName.C.

◆ fileName() [13/13]

fileName ( Istream is)
explicit

Definition at line 27 of file fileNameIO.C.

Member Function Documentation

◆ assign()

bool assign ( const token tok)

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(), and Foam::operator>>().

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

◆ valid()

bool valid ( char  c)
inlinestatic

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

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

Definition at line 211 of file fileName.C.

Referenced by dictionary::add(), dictionary::dictionary(), and scene::write().

Here is the caller graph for this function:

◆ equals()

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

Definition at line 238 of file fileName.C.

◆ stripInvalid()

void stripInvalid ( )
inline

Definition at line 106 of file fileNameI.H.

References Foam::expressions::patchExpr::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

◆ clean() [2/2]

bool clean ( )

Definition at line 383 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

Definition at line 353 of file fileName.C.

Referenced by 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

◆ isAbsolute() [2/2]

bool isAbsolute ( ) const
inline

Definition at line 151 of file fileNameI.H.

◆ toAbsolute()

Foam::fileName & toAbsolute ( )

Definition at line 370 of file fileName.C.

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

Here is the call graph for this function:

◆ isBackup() [1/2]

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

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

Definition at line 157 of file fileNameI.H.

◆ name() [1/3]

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

◆ name() [2/3]

Foam::word name ( ) const
inline

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:

◆ nameLessExt() [1/2]

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

Definition at line 389 of file fileName.C.

References Foam::dot().

Referenced by dlLibraryTable::basename(), surfaceNoise::calculate(), seriesWriter::print(), and seriesWriter::scan().

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

◆ nameLessExt() [2/2]

Foam::word nameLessExt ( ) const
inline

Definition at line 217 of file fileNameI.H.

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

Here is the caller graph for this function:

◆ name() [3/3]

word name ( const bool  noExt) const
inline

Definition at line 284 of file fileName.H.

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

Here is the call graph for this function:

◆ path() [1/2]

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

◆ path() [2/2]

Foam::fileName path ( ) const
inline

Definition at line 186 of file fileNameI.H.

References path().

Referenced by entry::New().

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

◆ hasPath()

bool hasPath ( ) const
inline

Definition at line 163 of file fileNameI.H.

References string::hasPath().

Here is the call graph for this function:

◆ removePath()

bool removePath ( )
inline

Definition at line 236 of file fileNameI.H.

References string::removePath().

Referenced by seriesWriter::append().

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

◆ relative()

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

Definition at line 418 of file fileName.C.

References f().

Here is the call graph for this function:

◆ lessExt()

Foam::fileName lessExt ( ) const
inline

◆ ext() [1/2]

Foam::word ext ( ) const
inline

◆ ext() [2/2]

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

Definition at line 242 of file fileNameI.H.

References string::ext().

Here is the call graph for this function:

◆ components()

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

Definition at line 454 of file fileName.C.

Referenced by dictionary::cfindScopedDict(), and mappedPatchBase::subRegistry().

Here is the caller graph for this function:

◆ component()

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

Definition at line 474 of file fileName.C.

◆ operator=() [1/9]

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

Definition at line 251 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

Definition at line 262 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

Definition at line 273 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

Definition at line 280 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

Definition at line 287 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

Definition at line 295 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

Definition at line 303 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

Definition at line 311 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

Definition at line 319 of file fileNameI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator/=()

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

Definition at line 499 of file fileName.C.

References s.

◆ hasExt() [1/4]

bool hasExt
inline

◆ hasExt() [2/4]

bool hasExt
inline

Definition at line 55 of file stringI.H.

◆ hasExt() [3/4]

bool hasExt
inline

Definition at line 61 of file stringI.H.

◆ hasExt() [4/4]

bool hasExt

Definition at line 74 of file string.C.

◆ removeExt()

bool removeExt
inline

Definition at line 89 of file stringI.H.

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

Here is the caller graph for this function:

Member Data Documentation

◆ typeName

const char *const typeName = "fileName"
static

Definition at line 90 of file fileName.H.

◆ debug

int debug
static

Definition at line 93 of file fileName.H.

◆ allowSpaceInFileName

int allowSpaceInFileName
static

Definition at line 96 of file fileName.H.

◆ null

const Foam::fileName null
static

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