Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | 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, FILE, DIRECTORY, LINK }
 Enumerations to handle file types and modes. More...
 

Public Member Functions

 fileName ()
 Construct null. More...
 
 fileName (const fileName &)
 Construct as copy. More...
 
 fileName (const word &)
 Construct as copy of word. More...
 
 fileName (const string &)
 Construct as copy of string. More...
 
 fileName (const std::string &)
 Construct as copy of std::string. More...
 
 fileName (const char *)
 Construct as copy 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...
 
Type type () const
 Return the file type: FILE, DIRECTORY or UNDEFINED. More...
 
bool isAbsolute () const
 Return true if file name is absolute. More...
 
fileNametoAbsolute ()
 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 /), subsitute 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= (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 char *)
 Construct as copy of character array. 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 (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...
 
stringreplace (const string &oldStr, const string &newStr, size_type start=0)
 Replace first occurence of sub-string oldStr with newStr. More...
 
stringreplaceAll (const string &oldStr, const string &newStr, size_type start=0)
 Replace all occurences of sub-string oldStr with newStr. More...
 
stringexpand (const bool allowEmpty=false)
 Expand initial tildes and all occurences 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...
 
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...
 
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

Istreamoperator>> (Istream &, fileName &)
 
Ostreamoperator<< (Ostream &, const fileName &)
 

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 69 of file fileName.H.

Member Enumeration Documentation

enum Type

Enumerations to handle file types and modes.

Enumerator
UNDEFINED 
FILE 
DIRECTORY 
LINK 

Definition at line 82 of file fileName.H.

Constructor & Destructor Documentation

fileName ( )
inline

Construct null.

Definition at line 52 of file fileNameI.H.

Referenced by Foam::operator/().

Here is the caller graph for this function:

fileName ( const fileName fn)
inline

Construct as copy.

Definition at line 57 of file fileNameI.H.

fileName ( const word w)
inline

Construct as copy of word.

Definition at line 62 of file fileNameI.H.

fileName ( const string str)
inline

Construct as copy of string.

Definition at line 68 of file fileNameI.H.

fileName ( const std::string &  str)
inline

Construct as copy of std::string.

Definition at line 76 of file fileNameI.H.

fileName ( const char *  str)
inline

Construct as copy of character array.

Definition at line 84 of file fileNameI.H.

fileName ( const wordList lst)
explicit

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

Definition at line 40 of file fileName.C.

References forAll, and fileName::operator=().

Here is the call graph for this function:

fileName ( Istream is)

Construct from Istream.

Definition at line 31 of file fileNameIO.C.

Member Function Documentation

bool valid ( char  c)
inlinestatic

Is this character valid for a fileName?

Definition at line 94 of file fileNameI.H.

References Foam::isspace().

Here is the call graph for this function:

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 77 of file fileName.C.

References Foam::constant::universal::c, Foam::constant::physicoChemical::c1, and resize().

Referenced by fileName::clean(), argList::postProcess(), and fileName::toAbsolute().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::fileName clean ( ) const

Cleanup file name.

eg, remove repeated slashes, etc.

Definition at line 171 of file fileName.C.

References fileName::clean().

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool isAbsolute ( ) const

Return true if file name is absolute.

Definition at line 57 of file fileName.C.

Referenced by chemkinReader::chemkinReader(), IOobject::fileNameComponents(), includeEntry::includeFileName(), Foam::ln(), argList::postProcess(), and fileName::toAbsolute().

Here is the caller graph for this function:

Foam::fileName & toAbsolute ( )

Convert from relative to absolute.

Definition at line 63 of file fileName.C.

References fileName::clean(), Foam::cwd(), f(), and fileName::isAbsolute().

Here is the call graph for this function:

Foam::word name ( ) const
Foam::string caseName ( ) const

Return file name (part beyond last /), subsitute for FOAM_CASE.

Definition at line 194 of file fileName.C.

References Foam::getEnv(), string::replace(), and string::string().

Referenced by IOobject::caseName().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::word name ( const bool  noExt) const

Return file name, optionally without extension.

Definition at line 213 of file fileName.C.

References Foam::dot(), and fileName::name().

Here is the call graph for this function:

Foam::fileName path ( ) const
Foam::fileName lessExt ( ) const
Foam::word ext ( ) const
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 298 of file fileName.C.

References DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), fileName::component(), and DynamicList< T, SizeInc, SizeMult, SizeDiv >::xfer().

Referenced by fileName::component(), and Foam::cp().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Return a single component of the path.

Definition at line 326 of file fileName.C.

References fileName::components().

Referenced by fileName::components(), and Foam::cp().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator= ( const fileName str)

Definition at line 337 of file fileName.C.

Referenced by fileName::fileName().

Here is the caller graph for this function:

void operator= ( const word str)

Definition at line 343 of file fileName.C.

void operator= ( const string str)

Definition at line 349 of file fileName.C.

void operator= ( const std::string &  str)

Definition at line 356 of file fileName.C.

void operator= ( const char *  str)

Definition at line 363 of file fileName.C.

Friends And Related Function Documentation

Istream& operator>> ( Istream ,
fileName  
)
friend
Ostream& operator<< ( Ostream ,
const fileName  
)
friend

Member Data Documentation

const char *const typeName = "fileName"
static

Definition at line 93 of file fileName.H.

int debug
static

Definition at line 94 of file fileName.H.

const Foam::fileName null
static

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