FreeFOAM The Cross-Platform CFD Toolkit
fileName Class Reference

A class for handling file names. More...

#include <OpenFOAM/fileName.H>


Detailed Description

A class for handling file names.

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

+ Inheritance diagram for fileName:
+ Collaboration diagram for fileName:

List of all members.

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 fileNameoperator= (const fileName &)
const fileNameoperator= (const word &)
const fileNameoperator= (const string &)
const fileNameoperator= (const std::string &)
const fileNameoperator= (const char *)
- Public Member Functions inherited from string
 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.
stringreplace (const string &oldStr, const string &newStr, size_type start=0)
 Replace first occurence of sub-string oldStr with newStr.
stringreplaceAll (const string &oldStr, const string &newStr, size_type start=0)
 Replace all occurences of sub-string oldStr with newStr.
stringexpand ()
 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?
- Static Public Member Functions inherited from string
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
- Static Public Attributes inherited from string

Friends

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

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.

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=().

fileName ( Istream is)

Construct from Istream.

Definition at line 34 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().

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::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.


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

Reimplemented from string.

Definition at line 93 of file fileName.H.

int debug
static

Reimplemented from string.

Definition at line 94 of file fileName.H.

const Foam::fileName null
static

Reimplemented from string.

Definition at line 95 of file fileName.H.

Referenced by chemkinReader::chemkinReader(), Time::dbDir(), and IOobject::filePath().


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