NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
FileSystem Class Reference

This class implements the basic input/ output file system and provides functionalities to work with filenames and folder paths. More...

#include <filesystem.hpp>

Inheritance diagram for FileSystem:
Collaboration diagram for FileSystem:

Public Member Functions

 FileSystem ()
 Default constructor. More...
 
FileSystemassign (const FileSystem &_fSys)
 Assignment member function to copy the settings from another FileSystem instance. More...
 
std::string ValidFileName (std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
 This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension. More...
 
std::string ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
 This member function evaluates, whether the passed foldername is a valid foldername. More...
 
std::string ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const
 This member function validizes the passed file name and creates the needed folders on-the-fly. More...
 
int setPath (std::string _sPath, bool bMkDir, std::string _sExePath)
 This member function may be used to set the preferred file path of the current FileSystem instance. More...
 
void createRevisionsFolder ()
 This member function creates the hidden revisions folders for the version control system. More...
 
std::string getPath () const
 Returns the default path of this FileSystem instance. More...
 
std::vector< std::string > getFileParts (const std::string &sFilePath) const
 This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More...
 
FileInfo getFileInfo (const std::string &sFilePath) const
 Return the file information about the passed file path. More...
 
void setTokens (std::string _sTokens)
 This member function may be used to update the path placeholders of the current FileSystem instance. More...
 
bool isFile (const std::string &_sPath) const
 This function determines, whether a path name indicates a file or a folder. More...
 
void initializeFromKernel ()
 Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More...
 
void setProgramPath (std::string _sExePath)
 
std::string getProgramPath () const
 
void declareFileType (const std::string &sFileType)
 

Protected Member Functions

int createFolders (const std::string &_sPath) const
 This member function creates all missing directories in the passed path. More...
 

Protected Attributes

std::string sPath
 
std::string sExecutablePath
 
std::string sTokens [7][2]
 
std::string sValidExtensions
 

Private Member Functions

std::string cleanPath (std::string sFilePath, bool checkInvalidChars) const
 This function cleans the passed file path, i.e. replaces the character encoding of umlauts, replaces path separators and path placeholders. More...
 
void resolveWildCards (std::string &_sFileName, bool isFile, bool checkExtension=true) const
 This member function resolves all wildcards, which may be found in the passed filename. More...
 

Detailed Description

This class implements the basic input/ output file system and provides functionalities to work with filenames and folder paths.

Definition at line 91 of file filesystem.hpp.

Constructor & Destructor Documentation

◆ FileSystem()

FileSystem::FileSystem ( )

Default constructor.

Definition at line 34 of file filesystem.cpp.

References sExecutablePath, sPath, sTokens, and sValidExtensions.

Member Function Documentation

◆ assign()

FileSystem & FileSystem::assign ( const FileSystem _fSys)

Assignment member function to copy the settings from another FileSystem instance.

Parameters
_fSysconst FileSystem&
Returns
FileSystem&

Definition at line 56 of file filesystem.cpp.

References sExecutablePath, sPath, sTokens, and sValidExtensions.

Referenced by initializeFromKernel().

◆ cleanPath()

std::string FileSystem::cleanPath ( std::string  sFilePath,
bool  checkInvalidChars 
) const
private

This function cleans the passed file path, i.e. replaces the character encoding of umlauts, replaces path separators and path placeholders.

Parameters
sFilePathstd::string
Returns
std::string

Definition at line 82 of file filesystem.cpp.

References checkInvalidChars(), NumeReKernel::issueWarning(), removeQuotationMarks(), replacePathSeparator(), sTokens, and StripSpaces().

Referenced by ValidFileName(), and ValidFolderName().

Here is the call graph for this function:

◆ createFolders()

int FileSystem::createFolders ( const std::string &  _sPath) const
protected

This member function creates all missing directories in the passed path.

Parameters
_sPathconst std::string&
Returns
int

Definition at line 234 of file filesystem.cpp.

Referenced by DocumentationGenerator::createLaTeXFileName(), createRevisionsFolder(), setPath(), and ValidizeAndPrepareName().

◆ createRevisionsFolder()

void FileSystem::createRevisionsFolder ( )

This member function creates the hidden revisions folders for the version control system.

Returns
void

Definition at line 532 of file filesystem.cpp.

References createFolders(), and sPath.

Referenced by NumeReKernel::StartUp().

Here is the call graph for this function:

◆ declareFileType()

void FileSystem::declareFileType ( const std::string &  sFileType)
inline

◆ getFileInfo()

FileInfo FileSystem::getFileInfo ( const std::string &  sFilePath) const

Return the file information about the passed file path.

Parameters
sFilePathconst std::string&
Returns
FileInfo

Definition at line 642 of file filesystem.cpp.

References FileInfo::creationTime, FileInfo::drive, FileInfo::ext, FileInfo::fileAttributes, FileInfo::filesize, getFileParts(), isFile(), FileInfo::modificationTime, FileInfo::name, FileInfo::path, ValidFileName(), ValidFolderName(), and windowSystemTimeToDouble().

Referenced by strfnc_getfileinfo().

Here is the call graph for this function:

◆ getFileParts()

std::vector< std::string > FileSystem::getFileParts ( const std::string &  sFilePath) const

This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths.

Parameters
sFilePathconst std::string&
Returns
std::vector<std::string>

Definition at line 566 of file filesystem.cpp.

References isFile(), ValidFileName(), and ValidFolderName().

Referenced by NumeRe::GenericFile::GenericFile(), NumeRe::getFileByType(), getFileInfo(), NumeRe::GenericFile::getTableName(), and strfnc_getFileParts().

Here is the call graph for this function:

◆ getPath()

std::string FileSystem::getPath ( ) const

◆ getProgramPath()

std::string FileSystem::getProgramPath ( ) const
inline

◆ initializeFromKernel()

void FileSystem::initializeFromKernel ( )

Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up.

Returns
void

Definition at line 750 of file filesystem.cpp.

References assign(), NumeReKernel::getFileSystem(), and NumeReKernel::getInstance().

Referenced by NumeRe::DataBase::DataBase(), NumeRe::GenericFile::GenericFile(), NumeRe::getFileByType(), CommandLineParser::getFileParameterValue(), CommandLineParser::getFileParameterValueForSaving(), Includer::Includer(), moveOrCopyFiles(), newObject(), CommandLineParser::parseFileName(), removeFile(), and writeToFile().

Here is the call graph for this function:

◆ isFile()

bool FileSystem::isFile ( const std::string &  _sPath) const

This function determines, whether a path name indicates a file or a folder.

Parameters
_sPathconst std::string&
Returns
bool

Definition at line 716 of file filesystem.cpp.

References fileExists(), and sValidExtensions.

Referenced by getFileInfo(), getFileParts(), and resolveWildCards().

Here is the call graph for this function:

◆ resolveWildCards()

void FileSystem::resolveWildCards ( std::string &  _sFileName,
bool  isFile,
bool  checkExtension = true 
) const
private

This member function resolves all wildcards, which may be found in the passed filename.

Parameters
_sFileNamestd::string&
isFilebool
checkExtenstionbool
Returns
void

Definition at line 159 of file filesystem.cpp.

References isFile(), sValidExtensions, and toLowerCase().

Referenced by ValidFileName(), and ValidFolderName().

Here is the call graph for this function:

◆ setPath()

int FileSystem::setPath ( std::string  _sPath,
bool  bMkDir,
std::string  _sExePath 
)

This member function may be used to set the preferred file path of the current FileSystem instance.

Parameters
_sPathstd::string
bMkDirbool
_sExePathstd::string
Returns
int

Definition at line 443 of file filesystem.cpp.

References createFolders(), fromSystemCodePage(), sExecutablePath, sPath, and sTokens.

Referenced by cmd_set(), DocumentationGenerator::DocumentationGenerator(), editObject(), executeCommand(), Includer::Includer(), NumeReKernel::MainLoop(), newObject(), saveDataObject(), NumeRe::FileAdapter::saveFile(), NumeReWindow::SaveTab(), NumeReKernel::StartUp(), strfnc_findfile(), and Procedure::writeProcedure().

Here is the call graph for this function:

◆ setProgramPath()

void FileSystem::setProgramPath ( std::string  _sExePath)
inline

Definition at line 122 of file filesystem.hpp.

References sExecutablePath.

◆ setTokens()

void FileSystem::setTokens ( std::string  _sTokens)

This member function may be used to update the path placeholders of the current FileSystem instance.

Parameters
_sTokensstd::string
Returns
void

Definition at line 694 of file filesystem.cpp.

References sTokens.

Referenced by cmd_set(), Settings::copySettings(), editObject(), executeCommand(), NumeReWindow::NumeReWindow(), saveDataObject(), NumeReKernel::StartUp(), and strfnc_findfile().

◆ ValidFileName()

std::string FileSystem::ValidFileName ( std::string  _sFileName,
const std::string  sExtension = ".dat",
bool  checkExtension = true,
bool  doCleanPath = true 
) const

This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension.

Parameters
_sFileNamestd::string
sExtensionconst std::string
checkExtensionbool
Returns
std::string

Definition at line 280 of file filesystem.cpp.

References cleanPath(), SyntaxError::INVALID_FILETYPE, resolveWildCards(), sPath, sValidExtensions, and toLowerCase().

Referenced by cmd_pack(), createPlotForHist1D(), createPlotsForHist2D(), doc_ReplaceTokensForHTML(), doc_SearchFct(), editObject(), evaluateFittingParams(), executeCommand(), Procedure::extractProcedureInformation(), fitDataSet(), generateTemplate(), NumeRe::GenericFile::GenericFile(), NumeRe::DataBase::getDBFileContent(), getFileInfo(), CommandLineParser::getFileParameterValue(), getFileParts(), NumeReKernel::getGreeting(), Documentation::getHelpArticle(), Language::getLangFileContent(), PackageManager::getPluginInfoPath(), getProcedureFileName(), Dependencies::getProcedureFileName(), Procedure::handleIncludeSyntax(), Script::handleInstallInformation(), is_file(), FunctionDefinitionManager::load(), MemoryManager::loadFromCacheFile(), PackageManager::loadPlugins(), Language::loadStrings(), moveOrCopyFiles(), NumeReWindow::NumeReWindow(), NumeRe::FileAdapter::openFile(), Includer::openIncludedFile(), Script::openScript(), CommandLineParser::parseFileName(), parseLayoutScript(), prepareTemplate(), FunctionDefinitionManager::save(), NumeRe::FileAdapter::saveFile(), MemoryManager::saveLayer(), MemoryManager::saveToCacheFile(), MemoryManager::setCacheFileName(), Output::setFileName(), PlotData::setParams(), Procedure::setProcName(), strfnc_findfile(), strfnc_sha256(), PackageManager::updatePluginFile(), NumeReWindow::UpdateToolbar(), ValidizeAndPrepareName(), Script::writeDocumentationArticle(), and Script::writeLayout().

Here is the call graph for this function:

◆ ValidFolderName()

std::string FileSystem::ValidFolderName ( std::string  _sFileName,
bool  doCleanPath = true,
bool  appendTrailingSeparator = true 
) const

This member function evaluates, whether the passed foldername is a valid foldername.

Parameters
_sFileNamestd::string
doCleanPathbool
appendTrailingSeparatorbool
Returns
std::string

Definition at line 369 of file filesystem.cpp.

References cleanPath(), fileExists(), resolveWildCards(), and sPath.

Referenced by cmd_unpack(), Documentation::createDocumentationIndex(), dialogCommand(), getFileInfo(), getFileParts(), is_dir(), and CommandLineParser::parseFileName().

Here is the call graph for this function:

◆ ValidizeAndPrepareName()

std::string FileSystem::ValidizeAndPrepareName ( const std::string &  _sFileName,
const std::string &  sExtension = ".dat" 
) const

This member function validizes the passed file name and creates the needed folders on-the-fly.

Parameters
_sFileNameconst std::string&
sExtensionconst std::string&
Returns
std::string

Definition at line 424 of file filesystem.cpp.

References createFolders(), and ValidFileName().

Referenced by doc_Help(), CommandLineParser::getFileParameterValueForSaving(), newObject(), PlotData::setFileName(), PlotData::setParams(), Archive::unpack(), and Script::writeWholeFile().

Here is the call graph for this function:

Member Data Documentation

◆ sExecutablePath

std::string FileSystem::sExecutablePath
protected

◆ sPath

◆ sTokens

◆ sValidExtensions

std::string FileSystem::sValidExtensions
mutableprotected

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