FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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 fileName &  operator= (const fileName &)
const fileName &  operator= (const word &)
const fileName &  operator= (const string &)
const fileName &  operator= (const std::string &)
const fileName &  operator= (const char *)

Static Public Member Functions

static bool  valid (char)
 Is this character valid for a fileName?

Static Public Attributes

static const char *const  typeName = "fileName"
static int  debug
static const fileName  null

Friends

Istream &  operator>> (Istream &, fileName &)
Ostream &  operator<< (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  ) [inline, static]

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: