NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class implements the basic input/ output file system and provides functionalities to work with filenames and folder paths. More...
#include <filesystem.hpp>
Public Member Functions | |
FileSystem () | |
Default constructor. More... | |
FileSystem & | assign (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... | |
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.
FileSystem::FileSystem | ( | ) |
Default constructor.
Definition at line 34 of file filesystem.cpp.
References sExecutablePath, sPath, sTokens, and sValidExtensions.
FileSystem & FileSystem::assign | ( | const FileSystem & | _fSys | ) |
Assignment member function to copy the settings from another FileSystem instance.
_fSys | const FileSystem& |
Definition at line 56 of file filesystem.cpp.
References sExecutablePath, sPath, sTokens, and sValidExtensions.
Referenced by initializeFromKernel().
|
private |
This function cleans the passed file path, i.e. replaces the character encoding of umlauts, replaces path separators and path placeholders.
sFilePath | std::string |
Definition at line 82 of file filesystem.cpp.
References checkInvalidChars(), NumeReKernel::issueWarning(), removeQuotationMarks(), replacePathSeparator(), sTokens, and StripSpaces().
Referenced by ValidFileName(), and ValidFolderName().
|
protected |
This member function creates all missing directories in the passed path.
_sPath | const std::string& |
Definition at line 234 of file filesystem.cpp.
Referenced by DocumentationGenerator::createLaTeXFileName(), createRevisionsFolder(), setPath(), and ValidizeAndPrepareName().
void FileSystem::createRevisionsFolder | ( | ) |
This member function creates the hidden revisions folders for the version control system.
Definition at line 532 of file filesystem.cpp.
References createFolders(), and sPath.
Referenced by NumeReKernel::StartUp().
|
inline |
Definition at line 132 of file filesystem.hpp.
References sValidExtensions.
Referenced by doc_Help(), editObject(), executeCommand(), moveOrCopyFiles(), CommandLineParser::parseFileName(), and strfnc_findfile().
FileInfo FileSystem::getFileInfo | ( | const std::string & | sFilePath | ) | const |
Return the file information about the passed file path.
sFilePath | const std::string& |
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().
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.
sFilePath | const 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().
std::string FileSystem::getPath | ( | ) | const |
Returns the default path of this FileSystem instance.
Definition at line 547 of file filesystem.cpp.
References sPath.
Referenced by NumeReKernel::CloseSession(), cmd_set(), DocumentationGenerator::createLaTeXFileName(), DocumentationGenerator::createMainFile(), DocumentationGenerator::createStyleFile(), Includer::Includer(), load_data(), and NumeReKernel::MainLoop().
|
inline |
Definition at line 127 of file filesystem.hpp.
References sExecutablePath.
Referenced by cmd_set(), MemoryManager::deleteTable(), Includer::Includer(), and NumeReKernel::MainLoop().
void FileSystem::initializeFromKernel | ( | ) |
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up.
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().
bool FileSystem::isFile | ( | const std::string & | _sPath | ) | const |
This function determines, whether a path name indicates a file or a folder.
_sPath | const std::string& |
Definition at line 716 of file filesystem.cpp.
References fileExists(), and sValidExtensions.
Referenced by getFileInfo(), getFileParts(), and resolveWildCards().
|
private |
This member function resolves all wildcards, which may be found in the passed filename.
_sFileName | std::string& |
isFile | bool |
checkExtenstion | bool |
Definition at line 159 of file filesystem.cpp.
References isFile(), sValidExtensions, and toLowerCase().
Referenced by ValidFileName(), and ValidFolderName().
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.
_sPath | std::string |
bMkDir | bool |
_sExePath | std::string |
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().
|
inline |
Definition at line 122 of file filesystem.hpp.
References sExecutablePath.
void FileSystem::setTokens | ( | std::string | _sTokens | ) |
This member function may be used to update the path placeholders of the current FileSystem instance.
_sTokens | std::string |
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().
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.
_sFileName | std::string |
sExtension | const std::string |
checkExtension | bool |
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().
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.
_sFileName | std::string |
doCleanPath | bool |
appendTrailingSeparator | bool |
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().
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.
_sFileName | const std::string& |
sExtension | const 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().
|
protected |
Definition at line 99 of file filesystem.hpp.
Referenced by assign(), FileSystem(), getProgramPath(), Settings::load(), Procedure::Procedure(), Settings::save(), NumeRe::FileAdapter::saveFile(), setPath(), and setProgramPath().
|
protected |
Definition at line 98 of file filesystem.hpp.
Referenced by assign(), createRevisionsFolder(), FileSystem(), Output::format(), Output::generateFileName(), getPath(), Output::Output(), Procedure::Procedure(), Settings::replaceExePath(), NumeRe::FileAdapter::saveFile(), PlotData::setFileName(), setPath(), ValidFileName(), and ValidFolderName().
|
protected |
Definition at line 100 of file filesystem.hpp.
Referenced by assign(), cleanPath(), FileSystem(), Procedure::Procedure(), PlotData::reset(), PlotData::setParams(), setPath(), setTokens(), Script::startInstallation(), and Procedure::writeProcedure().
|
mutableprotected |
Definition at line 101 of file filesystem.hpp.
Referenced by assign(), declareFileType(), FileSystem(), isFile(), resolveWildCards(), and ValidFileName().