www.cemf.ir
fileSystem Class Reference

Manages file pathes, manupulate and combines them. More...

Public Types

using pathType = std::filesystem::path
 

Public Member Functions

 fileSystem ()
 Default. More...
 
 fileSystem (const word &wPath)
 From full path. More...
 
 fileSystem (const word &dir, const word &file)
 From dir and file name. More...
 
 fileSystem (const char *dir, const char *file="")
 From dir and file name. More...
 
 fileSystem (const pathType &path)
 Copy. More...
 
 fileSystem (const fileSystem &)=default
 Copy. More...
 
 fileSystem (fileSystem &&)=default
 Move. More...
 
fileSystemoperator= (const fileSystem &)=default
 Copy assignment. More...
 
fileSystemoperator= (fileSystem &&)=default
 Move assignment. More...
 
 ~fileSystem ()=default
 Destructor. More...
 
bool isDir () const
 Is directory? More...
 
const pathTypepath () const
 Const access to path. More...
 
word wordPath () const
 Path in word type. More...
 
fileSystem dirPath () const
 Dir part of the path. More...
 
word fileName () const
 File name part of the path (if any) More...
 
fileSystem absolute () const
 Absolute path of this. More...
 
fileSystem canonical () const
 Canonical path of this (it should exist) More...
 
fileSystem relative (const fileSystem &base) const
 relative path of this this with respect to base More...
 
bool dirExist () const
 Only operate on dir path Check if the dir path exists. More...
 
bool exist () const
 Check if the path exists. More...
 
fileSystem createDirs () const
 Operate on dir path only Create dir based on the path and returns the canonical path. More...
 
void operator+= (const word &fileName)
 If this is dir path, add the filename to dir path if it is file path, replace the file name
More...
 
void operator/= (const fileSystem &fs)
 It operates on dir path only Add the dir path of fs to this
More...
 
fileSystem operator() (bool retDir=true) const
 Return the dir path of this. More...
 

Static Public Member Functions

static fileSystem CWD ()
 return current working directory More...
 

Static Protected Member Functions

static bool validFileName (const word &name)
 Is name is valid for a file? More...
 
static bool checkFileName (const word &name)
 Is a valid file name? More...
 

Protected Attributes

pathType path_
 File path. More...
 
bool isDir_
 Is this a directory path? More...
 

Static Protected Attributes

static word notPermittedCharsFile = word(" ") + word("&\t\n;:?*/<>\"?\'")
 Not premitted chars in file name
More...
 

Friends

fileSystem operator/ (const fileSystem &fs1, const fileSystem &fs2)
 Create a dir path from dir path of fs1 and fas2 in the form of fs1/fs2
More...
 
iOstreamoperator<< (iOstream &os, const fileSystem &fs)
 
std::ostream & operator<< (std::ostream &os, const fileSystem &fs)
 

Detailed Description

Manages file pathes, manupulate and combines them.

Definition at line 71 of file fileSystem.hpp.

Member Typedef Documentation

◆ pathType

using pathType = std::filesystem::path

Definition at line 75 of file fileSystem.hpp.

Constructor & Destructor Documentation

◆ fileSystem() [1/7]

fileSystem ( )
inline

Default.

Definition at line 111 of file fileSystem.hpp.

Referenced by fileSystem::CWD().

+ Here is the caller graph for this function:

◆ fileSystem() [2/7]

fileSystem ( const word wPath)
explicit

From full path.

Definition at line 44 of file fileSystem.cpp.

References fileSystem::checkFileName(), fatalExit, fileSystem::fileName(), and fileSystem::isDir_.

+ Here is the call graph for this function:

◆ fileSystem() [3/7]

fileSystem ( const word dir,
const word file 
)

From dir and file name.

Definition at line 55 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

+ Here is the call graph for this function:

◆ fileSystem() [4/7]

fileSystem ( const char *  dir,
const char *  file = "" 
)

From dir and file name.

Definition at line 78 of file fileSystem.cpp.

◆ fileSystem() [5/7]

fileSystem ( const pathType path)
explicit

Copy.

Definition at line 85 of file fileSystem.cpp.

◆ fileSystem() [6/7]

fileSystem ( const fileSystem )
default

Copy.

◆ fileSystem() [7/7]

fileSystem ( fileSystem &&  )
default

Move.

◆ ~fileSystem()

~fileSystem ( )
default

Destructor.

Member Function Documentation

◆ validFileName()

static bool validFileName ( const word name)
inlinestaticprotected

Is name is valid for a file?

Definition at line 90 of file fileSystem.hpp.

References fileSystem::notPermittedCharsFile.

Referenced by fileSystem::checkFileName().

+ Here is the caller graph for this function:

◆ checkFileName()

bool checkFileName ( const word name)
staticprotected

Is a valid file name?

Definition at line 27 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, fileSystem::notPermittedCharsFile, and fileSystem::validFileName().

Referenced by fileSystem::fileSystem().

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

◆ CWD()

static fileSystem CWD ( )
inlinestatic

return current working directory

Definition at line 101 of file fileSystem.hpp.

References fileSystem::fileSystem().

Referenced by pFlow::CWD().

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

◆ operator=() [1/2]

fileSystem& operator= ( const fileSystem )
default

Copy assignment.

◆ operator=() [2/2]

fileSystem& operator= ( fileSystem &&  )
default

Move assignment.

◆ isDir()

bool isDir ( ) const
inline

Is directory?

Definition at line 148 of file fileSystem.hpp.

References fileSystem::isDir_.

◆ path()

const pathType& path ( ) const
inline

Const access to path.

Definition at line 154 of file fileSystem.hpp.

References fileSystem::path_.

Referenced by pFlow::containingFiles(), pFlow::isDirectory(), pFlow::isRegularFile(), repository::path(), IOfileHeader::path(), and pFlow::subDirectories().

+ Here is the caller graph for this function:

◆ wordPath()

◆ dirPath()

pFlow::fileSystem dirPath ( ) const

Dir part of the path.

Definition at line 91 of file fileSystem.cpp.

Referenced by fileStream::openOutFile(), and pFlow::operator/().

+ Here is the caller graph for this function:

◆ fileName()

pFlow::word fileName ( ) const

File name part of the path (if any)

Definition at line 105 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

Referenced by fileSystem::fileSystem().

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

◆ absolute()

pFlow::fileSystem absolute ( ) const

Absolute path of this.

Definition at line 125 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, fatalExit, fileSystem::isDir_, and fileSystem::path_.

+ Here is the call graph for this function:

◆ canonical()

pFlow::fileSystem canonical ( ) const

Canonical path of this (it should exist)

Definition at line 149 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, fatalExit, fileSystem::isDir_, and fileSystem::path_.

Referenced by systemControl::getRunName(), and systemControl::getTopFolder().

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

◆ relative()

pFlow::fileSystem relative ( const fileSystem base) const

relative path of this this with respect to base

Definition at line 170 of file fileSystem.cpp.

References fileSystem::path_.

Referenced by fileSeries::addTimeFile().

+ Here is the caller graph for this function:

◆ dirExist()

bool dirExist ( ) const

Only operate on dir path Check if the dir path exists.

Definition at line 176 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

+ Here is the call graph for this function:

◆ exist()

bool exist ( ) const

Check if the path exists.

Definition at line 192 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

Referenced by fileStream::openInFile().

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

◆ createDirs()

pFlow::fileSystem createDirs ( ) const

Operate on dir path only Create dir based on the path and returns the canonical path.

Definition at line 208 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

Referenced by fileStream::openOutFile().

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

◆ operator+=()

void operator+= ( const word fileName)

If this is dir path, add the filename to dir path if it is file path, replace the file name

Definition at line 245 of file fileSystem.cpp.

References fatalExit.

◆ operator/=()

void operator/= ( const fileSystem fs)

It operates on dir path only Add the dir path of fs to this

Definition at line 265 of file fileSystem.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

+ Here is the call graph for this function:

◆ operator()()

pFlow::fileSystem operator() ( bool  retDir = true) const

Return the dir path of this.

Definition at line 235 of file fileSystem.cpp.

Friends And Related Function Documentation

◆ operator/

fileSystem operator/ ( const fileSystem fs1,
const fileSystem fs2 
)
friend

Create a dir path from dir path of fs1 and fas2 in the form of fs1/fs2

◆ operator<< [1/2]

iOstream& operator<< ( iOstream os,
const fileSystem fs 
)
friend

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const fileSystem fs 
)
friend

Member Data Documentation

◆ path_

◆ isDir_

bool isDir_
protected

Is this a directory path?

Definition at line 83 of file fileSystem.hpp.

Referenced by fileSystem::absolute(), fileSystem::canonical(), fileSystem::fileSystem(), and fileSystem::isDir().

◆ notPermittedCharsFile

word notPermittedCharsFile = word(" ") + word("&\t\n;:?*/<>\"?\'")
inlinestaticprotected

Not premitted chars in file name

Definition at line 87 of file fileSystem.hpp.

Referenced by fileSystem::checkFileName(), and fileSystem::validFileName().


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