OpenASIP 2.2
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
FileSystem Class Reference

#include <FileSystem.hh>

Collaboration diagram for FileSystem:
Collaboration graph

Static Public Member Functions

static bool fileExists (const std::string fileName)
 
static bool fileIsWritable (const std::string fileName)
 
static bool fileIsReadable (const std::string fileName)
 
static bool fileIsExecutable (const std::string fileName)
 
static bool fileIsCreatable (const std::string fileName)
 
static bool fileIsDirectory (const std::string fileName)
 
static std::string directoryOfPath (const std::string fileName)
 
static std::string fileOfPath (const std::string pathName)
 
static bool isAbsolutePath (const std::string &pathName)
 
static bool isRelativePath (const std::string &pathName)
 
static bool isPath (const std::string &pathName)
 
static std::string fileExtension (const std::string &fileName)
 
static std::string fileNameBody (const std::string &fileName)
 
static std::string absolutePathOf (const std::string &pathName)
 
static std::string currentWorkingDir ()
 
static bool changeWorkingDir (const std::string &path)
 
static std::string homeDirectory ()
 
static bool setFileExecutable (const std::string fileName)
 
static std::time_t lastModificationTime (const std::string &filePath)
 
static uintmax_t sizeInBytes (const std::string &filePath)
 
static bool runShellCommand (const std::string command)
 
static void globPath (const std::string &pattern, std::vector< std::string > &filenames)
 
static std::string expandTilde (const std::string &stringWithTilde)
 
static bool createDirectory (const std::string &path)
 
static std::string createTempDirectory (const std::string &path="/tmp", const std::string &tempDirPrefix="tmp_tce_")
 
static bool createFile (const std::string &file)
 
static bool removeFileOrDirectory (const std::string &path)
 
static void copy (const std::string &source, const std::string &target)
 
static std::string findFileInSearchPaths (const std::vector< std::string > &searchPaths, const std::string &file)
 
static std::vector< std::string > directoryContents (const std::string &directory, const bool absolutePaths=true)
 
static std::vector< std::string > directorySubTrees (const std::string &directory)
 
static bool findFileInDirectoryTree (const Path &startDirectory, const std::string &fileName, Path &pathFound)
 
template<typename STLCONT >
static bool findFromDirectory (const std::string &regex, const std::string &directory, STLCONT &found)
 
template<typename STLCONT >
static bool findFromDirectoryRecursive (const std::string &regex, const std::string &directory, STLCONT &found)
 
static bool compareFileNames (const std::string &first, const std::string &second, const std::string &rootDirectory)
 
static bool relativeDir (const std::string &baseDir, std::string &toRelDir)
 
static bool makeRelativePath (const std::vector< std::string > &searchPaths, const std::string &basePath, std::string &toRelPath)
 
static bool readBlockFromFile (const std::string &sourceFile, const std::string &blockStartRE, const std::string &blockEndRE, std::string &readBlock, const bool includeMatchingLines=true)
 
static bool appendReplaceFile (const std::string &targetFile, const std::string &ARStartRE, const std::string &writeToFile, const std::string &AREndRE="", const bool discardBlockBorder="true")
 
static int countLines (const std::string &filepath)
 

Static Public Attributes

static const std::string DIRECTORY_SEPARATOR
 
static const std::string CURRENT_DIRECTORY = "."
 
static const std::string STRING_WILD_CARD = "*"
 

Detailed Description

Portability layer for platform-dependent functions that access the filesystem.

Definition at line 86 of file FileSystem.hh.

Member Function Documentation

◆ absolutePathOf()

string FileSystem::absolutePathOf ( const std::string &  pathName)
static

Returns the given path as absolute path.

Parameters
pathNameThe path.
Returns
The absolute path.

Definition at line 303 of file FileSystem.cc.

303 {
304 string absolutePath("");
305 if (isAbsolutePath(pathName)) {
306 absolutePath = pathName;
307 } else {
308 absolutePath = currentWorkingDir() + DIRECTORY_SEPARATOR + pathName;
309 }
310 Path path(absolutePath);
311 path.normalize();
312 return path.string();
313}
static bool isAbsolutePath(const std::string &pathName)
static const std::string DIRECTORY_SEPARATOR
static std::string currentWorkingDir()

References currentWorkingDir(), DIRECTORY_SEPARATOR, and isAbsolutePath().

Referenced by HDB::HDBRegistry::addHDB(), createDirectory(), PlatformIntegrator::createOutputDir(), directoryContents(), ProcessorImplementationWindow::doSaveIDF(), DSDBManager::dsdbFile(), ProGeScriptGenerator::fetchFiles(), HDB::HDBManager::fileName(), findFileInSearchPaths(), GenerateProcessor::getOutputDir(), HDB::HDBRegistry::hasHDB(), HDB::HDBRegistry::hdb(), ImplementationTester::ImplementationTester(), ImplementationTester::ImplementationTester(), ProGe::ProGeUI::integrateProcessor(), HDB::HDBRegistry::loadFromSearchPaths(), Environment::osalPaths(), PlatformIntegrator::outputFilePath(), PlatformIntegrator::progeFilePath(), PlatformIntegrator::setSharedOutputDir(), PlatformIntegrator::tbFilePath(), and ProGeOptions::validate().

Here is the call graph for this function:

◆ appendReplaceFile()

bool FileSystem::appendReplaceFile ( const std::string &  targetFile,
const std::string &  ARStartRE,
const std::string &  writeToFile,
const std::string &  AREndRE = "",
const bool  discardBlockBorder = "true" 
)
static

Appends to specified place in file, can replace a section.

Doesn't use temp files so uses lot of memory for big files.

Parameters
targetFileFile to be edited.
ARStartRERegex that matches the line where appending starts.
writeToFileString that is written to the file.
AREndRERegex that matches last line that is replaced or deleted if writeToFile string contains less lines than is between start and end matches.
discardBlockBorderIf true Regex matching lines are replaced or deleted.
Returns
True if something was writen to the file, otherwise false.

Definition at line 958 of file FileSystem.cc.

963 {
964
965 const int LINESIZE = 1000;
966 char line[LINESIZE];
967
968 const boost::regex reStart(ARStartRE,
969 boost::regex::perl|boost::regex::icase);
970 boost::regex reEnd;
971 if (!AREndRE.empty()) {
972 reEnd = boost::regex(AREndRE, boost::regex::perl|boost::regex::icase);
973 }
974 boost::regex re = reStart;
975
976 string::const_iterator begin;
977 string::const_iterator end;
978 string stemp = "";
979 string endFile = "";
980 int blockStartPos = -1;
981 std::fstream fs(targetFile.c_str(), std::fstream::in | std::fstream::out);
982 boost::match_results<string::const_iterator> matches;
983
984 bool beforeBlock = true;
985 bool afterBlock = false;
986 while (fs.good()) {
987
988 fs.getline(line, LINESIZE-1);
989
990 if (fs.eof()) {
991 if (blockStartPos != -1) {
992 fs.clear();
993 fs.seekp(blockStartPos);
994 fs.seekg(blockStartPos);
995 } else {
996 // no place of appending was found, ARStartRE didn't match any
997 // line
998 fs.close();
999 return false;
1000 }
1001
1002 if (!fs.good()) {
1003 fs.close();
1004 return false;
1005 }
1006
1007 fs.write(writeToFile.c_str(), writeToFile.length());
1008 fs.write(endFile.c_str(), endFile.length());
1009
1010 if (truncate(targetFile.c_str(), fs.tellp()) != 0) {
1011 abortWithError("truncate failed!");
1012 }
1013
1014 break;
1015 }
1016
1017 stemp = string(line);
1018 begin = stemp.begin();
1019 end = stemp.end();
1020
1021 // test if found block border
1022 if (!afterBlock && boost::regex_search(begin, end, re)) {
1023 if (beforeBlock) {
1024 // to inside replace block
1025 beforeBlock = false;
1026 // if no replace block end then no searching for it
1027 afterBlock = AREndRE.empty() ? true : afterBlock;
1028
1029 if (discardBlockBorder) {
1030 blockStartPos = static_cast<int>(fs.tellg()) -
1031 static_cast<int>(fs.gcount());
1032 } else {
1033 blockStartPos = fs.tellg();
1034 }
1035 re = reEnd;
1036 } else {
1037 // to outside replace block
1038 if (!discardBlockBorder) {
1039 endFile.append(stemp + "\n");
1040 }
1041 afterBlock = true;
1042 }
1043 } else if (afterBlock) {
1044 // outside replace block
1045 endFile.append(stemp + "\n");
1046 }
1047 }
1048
1049 fs.close();
1050 return true;
1051}
#define abortWithError(message)

References abortWithError.

Referenced by ProGeTestBenchGenerator::createProcArchVhdl().

◆ changeWorkingDir()

bool FileSystem::changeWorkingDir ( const std::string &  path)
static

Changes the working directory to a new one

Parameters
pathThe new working directory to be set
Returns
true on success, false on error

Definition at line 185 of file FileSystem.cc.

185 {
186 return (chdir(path.c_str()) == 0);
187}

Referenced by GhdlSimulator::compile(), ModelsimSimulator::compile(), GhdlSimulator::simulate(), and ImplementationSimulator::~ImplementationSimulator().

◆ compareFileNames()

bool FileSystem::compareFileNames ( const std::string &  first,
const std::string &  second,
const std::string &  rootDirectory 
)
static

Compares two file names considering path.

Compares two strings representing file names that can be with absolut or relative paths. Relative paths are interpreted against given root directory parameter.

Parameters
firstFile name to be compared.
secondFile name to be compared.
rootDirectoryBase dir for relative paths in file names.
Returns
True if file names are same considering path, otherwise false.

Definition at line 724 of file FileSystem.cc.

727 {
728
729 std::string testRootDir = rootDirectory;
730 if (rootDirectory.substr(rootDirectory.size()-1) != DIRECTORY_SEPARATOR) {
731 testRootDir += DIRECTORY_SEPARATOR;
732 }
733
734 if (first == second) {
735 return true;
736 }
737
738 if (FileSystem::isRelativePath(first) &&
740 return false;
741 } else if (FileSystem::isRelativePath(first)) {
742 return ((testRootDir + first) == second) ? true : false;
743 } else if (FileSystem::isRelativePath(second)) {
744 return ((testRootDir + second) == first) ? true : false;
745 }
746
747 return false;
748}
static bool isRelativePath(const std::string &pathName)

References DIRECTORY_SEPARATOR, and isRelativePath().

Referenced by ProGeScriptGenerator::sortFilesFirst(), and ProGeScriptGenerator::sortFilesLast().

Here is the call graph for this function:

◆ copy()

void FileSystem::copy ( const std::string &  source,
const std::string &  target 
)
static

Copies source file to target file.

Copying can fail for the following reasons: Source file doesn't exist, source is directory, or target string is empty.

If target file already exists then it's removed and source file is copied in its place. If target file is a existing directory copies the file under it without changing the files name.

Parameters
sourceFile to be copied.
targetTarget of the copy operation.
Exceptions
IOExceptionin case the copying failed.

Definition at line 524 of file FileSystem.cc.

524 {
525 namespace fs = boost::filesystem;
526 Path sourcePath(source);
527 Path targetPath(target);
528
529 try {
530 if (fs::exists(targetPath)) {
531 if(!fileIsDirectory(target)) {
532 fs::remove(targetPath);
533 } else {
534 fs::path::iterator lastIt = --(sourcePath.end());
535 targetPath /= *lastIt;
536 // The target directory may have already a file by name
537 if(!fileIsDirectory(targetPath.string())) {
538 fs::remove(targetPath);
539 }
540 }
541 }
542 fs::copy_file(sourcePath, targetPath);
543 } catch (boost::filesystem::filesystem_error const& e) {
544 throw IOException(
545 __FILE__, __LINE__, __func__,
546 (boost::format(
547 "Unable to copy '%s' to '%s'") %
548 sourcePath.string() % targetPath.string()).str());
549 }
550}
#define __func__
static bool fileIsDirectory(const std::string fileName)

References __func__, and fileIsDirectory().

Referenced by ProGe::BlockSourceCopier::copyFiles(), copyImageToTb(), FUGen::copyImplementation(), AlmaIFIntegrator::copyPlatformFile(), ProGe::BlockSourceCopier::copyProcessorSpecific(), ProGe::BlockSourceCopier::copyShared(), ProGeTestBenchGenerator::copyTestBenchFiles(), OSEdModifyBehaviorCmd::Do(), XilinxBlockRamGenerator::generateComponentFile(), AlmaIFIntegrator::generateIntegratedTestbench(), OperationBuilder::installDataFile(), OperationPropertyDialog::onOpen(), and runShellCommand().

Here is the call graph for this function:

◆ countLines()

int FileSystem::countLines ( const std::string &  filepath)
static

Counts lines in a file.

Parameters
filepathPath to the file.
Returns
The count if successful. On error returns negative number.

Definition at line 1060 of file FileSystem.cc.

1060 {
1061 std::ifstream fileStream(filepath);
1062 if (!fileStream.is_open()) {
1063 return -1;
1064 }
1065 unsigned count = 0;
1066 std::string dummyLine;
1067 while (std::getline(fileStream, dummyLine)) {
1068 count++;
1069 }
1070 return count;
1071}

◆ createDirectory()

bool FileSystem::createDirectory ( const std::string &  path)
static

Creates a directory if it doesn't already exist.

All non-existing directories in the path are created.

Parameters
pathThe path of directory.
Returns
True if directory is created, false otherwise.

Definition at line 400 of file FileSystem.cc.

400 {
401 std::string p = path;
402 if (!isAbsolutePath(p)) {
403 p = absolutePathOf(p);
404 }
406 Path orPath(p.substr(1));
407 string origPath = orPath.string();
408 string currentPath = DS.string();
409 while (origPath.size() > 0) {
410 string::size_type pos = origPath.find(DS.string());
411 if (pos == string::npos) {
412 currentPath += origPath;
413 origPath = "";
414 } else {
415 currentPath += origPath.substr(0, pos);
416 origPath.replace(0, pos + 1, "");
417 }
418 try {
419 Path dirPath(currentPath);
420 if (!boost::filesystem::exists(dirPath)) {
421 boost::filesystem::create_directory(dirPath);
422 }
423 } catch (...) {
424 // directory creation failed, probably because of lacking rights
425 return false;
426 }
427 currentPath += DS.string();
428 }
429 return true;
430}
#define DS
static std::string absolutePathOf(const std::string &pathName)

References absolutePathOf(), DIRECTORY_SEPARATOR, DS, and isAbsolutePath().

Referenced by Environment::bitmapsDirPath(), ProGe::BlockSourceCopier::copyFiles(), FUGen::copyImplementation(), ProGe::BlockSourceCopier::copyProcessorSpecific(), ProGeTestBenchGenerator::copyTestBenchFiles(), FUGen::createImplementationFiles(), PlatformIntegrator::createOutputDir(), LLVMBackend::createPlugin(), createTempDirectory(), ImplementationSimulator::createWorkDir(), Environment::dataDirPath(), OSEdAddModuleCmd::Do(), Environment::errorLogFilePath(), AlmaIFIntegrator::generateIntegratedTestbench(), ProGe::ProcessorGenerator::generateProcessor(), Environment::iconDirPath(), Environment::initialize(), OperationBuilder::installDataFile(), ProGe::BlockSourceCopier::instantiateHDLTemplate(), OSEdAddModuleCmd::isEnabled(), Environment::manDirPath(), Environment::schemaDirPath(), ProGe::NetlistBlock::write(), and ProGe::TestBenchBlock::write().

Here is the call graph for this function:

◆ createFile()

bool FileSystem::createFile ( const std::string &  file)
static

Creates a file if it doesn't already exist.

Parameters
fileThe name of the file.
Returns
True if file is created, false otherwise.

Definition at line 468 of file FileSystem.cc.

468 {
469
470 Path filePath(file);
471 string fileName = filePath.string();
472
473 if (fileExists(file)) {
474 return true;
475 }
476
477 if (fileIsCreatable(fileName)) {
478 FILE* f = fopen(fileName.c_str(), "w");
479 fclose(f);
480 return true;
481 } else {
482 return false;
483 }
484}
static bool fileIsCreatable(const std::string fileName)
static bool fileExists(const std::string fileName)

References fileExists(), and fileIsCreatable().

Referenced by Environment::confPath(), createCompressor(), ProGeScriptGenerator::createExecutableFile(), ProGeTestBenchGenerator::createFile(), createMauPkg(), Environment::errorLogFilePath(), ProGe::ProcessorGenerator::generateGlobalsPackage(), DefaultDecoderGenerator::generateInstructionDecoder(), DefaultICGenerator::generateInterconnectionNetwork(), DefaultICGenerator::generateSocket(), OSEdAddModuleCmd::isEnabled(), OSEdAddOperationCmd::isEnabled(), main(), and Environment::userConfPath().

Here is the call graph for this function:

◆ createTempDirectory()

std::string FileSystem::createTempDirectory ( const std::string &  path = "/tmp",
const std::string &  tempDirPrefix = "tmp_tce_" 
)
static

Creates a temporary directory to the given path

Parameters
pathPath to create the temporary directory in
tempDirPrefixPrefix string before randomly generated string part.
Returns
Full path to the generated temporary directory. Empty string on error.

Definition at line 441 of file FileSystem.cc.

443 {
444 const int RANDOM_CHARS = 10;
445 const string DS(DIRECTORY_SEPARATOR);
446 string tempDir = path + DS + tempDirPrefix;
447
448 for (int i = 0; i < RANDOM_CHARS || fileExists(tempDir); ++i) {
449 tempDir += static_cast<char>(MathTools::random('0', '9'));
450 tempDir += static_cast<char>(MathTools::random('a', 'z'));
451 tempDir += static_cast<char>(MathTools::random('A', 'Z'));
452 }
453
454 if (!createDirectory (tempDir)) {
455 return "";
456 } else {
457 return tempDir;
458 }
459}
static bool createDirectory(const std::string &path)
static int random(int, int)

References createDirectory(), DIRECTORY_SEPARATOR, DS, fileExists(), and MathTools::random().

Referenced by CompileTools::compileAsC(), CompileTools::compileAsLLVM(), ImplementationTester::createTempDir(), CompiledSimController::reset(), DesignSpaceExplorer::schedule(), and OperationDAGDialog::updateDAG().

Here is the call graph for this function:

◆ currentWorkingDir()

std::string FileSystem::currentWorkingDir ( )
static

Returns the current working directory.

Returns
The current working directory or, in case of error, an empty string.

Definition at line 142 of file FileSystem.cc.

142 {
143
144 // the amount of bytes to stretch the char buffer if the path doesn't
145 // fit in it
146 const int increment = 100;
147 int bufSize = 200;
148 char* buf = new char[bufSize];
149
150 // sets errno to ERANGE if buffer was too small
151 char* retValue = getcwd(buf, bufSize);
152
153 // grow the buffer until the path fits in it
154 while (retValue == NULL && errno == ERANGE) {
155 delete[] buf;
156 bufSize += increment;
157 buf = new char[bufSize];
158 retValue = getcwd(buf, bufSize);
159 }
160
161 std::string dirName = "";
162 if (retValue == NULL) {
163
164 std::string procName = "FileSystem::currentWorkingDir";
165 std::string errorMsg = "Current working directory cannot be read.";
166 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
167
168 assert(errno == EACCES);
169 } else {
170 dirName = buf;
171 }
172
173 delete[] buf;
174 Path path(dirName);
175 return path.string();
176}
#define assert(condition)
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)

References assert, and Application::writeToErrorLog().

Referenced by absolutePathOf(), OperationBuilder::behaviorFile(), OperationBuilder::buildObject(), IDF::MachineImplementation::checkImplFiles(), Environment::codeCompressorPaths(), CompileTools::compileAsC(), CompileTools::compileAsLLVM(), Environment::decompressorPaths(), ProcessorImplementationWindow::doSaveIDF(), Environment::estimatorPluginPaths(), Environment::explorerPluginPaths(), GenerateProcessor::generateProcessor(), GenerateProcessor::getOutputDir(), Environment::hdbPaths(), Environment::hwModulePaths(), Environment::icDecoderPluginPaths(), ImplementationSimulator::ImplementationSimulator(), XMLSerializer::initializeParser(), Environment::longHDBPath(), main(), Environment::osalPaths(), Environment::schedulerPluginPaths(), Environment::shortHDBPath(), TTASimulatorCLI::TTASimulatorCLI(), Environment::vhdlPaths(), and OperationBuilder::xmlFilePath().

Here is the call graph for this function:

◆ directoryContents()

std::vector< std::string > FileSystem::directoryContents ( const std::string &  directory,
const bool  absolutePaths = true 
)
static

Returns the files found in the given directory.

Parameters
directoryThe directory.
Returns
Vector containing the files.
Exceptions
FileNotFoundIf the given directory does not exist.

Definition at line 600 of file FileSystem.cc.

601 {
602 try {
603 std::vector<std::string> contents;
604 // default construction yields past the end
605 boost::filesystem::directory_iterator end_iter;
606
607 if (directory != "") {
608 Path path(directory);
609 for (boost::filesystem::directory_iterator iter(path);
610 iter != end_iter; iter++) {
611 if (absolutePaths) {
612 contents.push_back(absolutePathOf(iter->path().string()));
613 } else {
614 contents.push_back(iter->path().string());
615 }
616
617 }
618 } else {
619 for (boost::filesystem::directory_iterator iter(
620 boost::filesystem::current_path());
621 iter != end_iter; iter++) {
622 if (absolutePaths) {
623 contents.push_back(absolutePathOf(iter->path().string()));
624 } else {
625 contents.push_back(iter->path().string());
626 }
627 }
628 }
629
630 return contents;
631
632 } catch (const boost::filesystem::filesystem_error& e) {
633 throw FileNotFound(__FILE__, __LINE__, __func__, e.what());
634 }
635}

References __func__, and absolutePathOf().

Referenced by ProgramImageGenerator::availableCompressors(), ProGeScriptGenerator::fetchFiles(), HDB::HDBRegistry::loadFromSearchPaths(), and PlatformIntegrator::progeOutputHdlFiles().

Here is the call graph for this function:

◆ directoryOfPath()

std::string FileSystem::directoryOfPath ( const std::string  fileName)
static

Returns the path part of the given file name.

Parameters
fileNameA file name with a (partial or absolute) path.
Returns
Path part of the file name.

Definition at line 79 of file FileSystem.cc.

79 {
80
81 Path origString(fileName);
82 string file = origString.string();
84 string::size_type lastPathPos = file.rfind(DS.string());
85 if (lastPathPos == string::npos) {
86 return CURRENT_DIRECTORY;
87 }
88
89 string dirPath = file.substr(0, lastPathPos);
90 Path path(dirPath);
91 return path.string();
92}
static const std::string CURRENT_DIRECTORY

References CURRENT_DIRECTORY, DIRECTORY_SEPARATOR, and DS.

Referenced by CompiledSimulation::compileAndLoadFunction(), CompiledSimCompiler::compileFile(), ImplementationTester::createListOfSimulationFiles(), IDF::MachineImplementation::decompressorFile(), ProcessorImplementationWindow::doSaveIDF(), fileIsCreatable(), FUGen::findAbsolutePath(), IDF::UnitImplementationLocation::hdbFile(), IDF::MachineImplementation::icDecoderHDB(), IDF::MachineImplementation::icDecoderPluginFile(), ImplementationSimulator::ImplementationSimulator(), ProGe::ProGeUI::loadProcessorConfiguration(), SimulatorFrontend::loadProcessorConfiguration(), main(), OSEdOptionsDialog::onBrowse(), BlockImplementationFileDialog::onBrowse(), MDFDocument::openCFG(), OperationModule::OperationModule(), OperationModule::operator=(), IDF::MachineImplementation::setDecompressorFile(), IDF::MachineImplementation::setICDecoderHDB(), IDF::MachineImplementation::setICDecoderPluginFile(), and Environment::vhdlPaths().

◆ directorySubTrees()

std::vector< std::string > FileSystem::directorySubTrees ( const std::string &  directory)
static

Returns all the sub-directories found starting from the given directory. Uses recursion to find out all the possible sub-directory levels as well.

Parameters
directoryThe directory where to search. Not listed in the results!
Returns
Vector containing the sub-directories (and their sub-dirs, and...).
Note
This function will not search the directories containing "." !
Exceptions
FileNotFoundIf the given directory does not exist.

Definition at line 647 of file FileSystem.cc.

647 {
648 std::vector<std::string> subTrees;
649
650 try {
651 directory_iterator end_itr;
652
653 for (directory_iterator itr(directory); itr != end_itr; ++itr) {
654 if (is_directory(*itr) && exists(*itr) &&
655 (*itr).path().string().find(".") == string::npos) {
656 subTrees.push_back((*itr).path().string());
657
658 std::vector<std::string> subSubTrees =
659 directorySubTrees((*itr).path().string());
660
661 for (size_t i = 0; i < subSubTrees.size(); ++i) {
662 subTrees.push_back(subSubTrees.at(i));
663 }
664 }
665 }
666 } catch (const boost::filesystem::filesystem_error& e) {
667 throw FileNotFound(__FILE__, __LINE__, __func__, e.what());
668 }
669
670 return subTrees;
671}
static std::vector< std::string > directorySubTrees(const std::string &directory)

References __func__, and directorySubTrees().

Referenced by directorySubTrees().

Here is the call graph for this function:

◆ expandTilde()

string FileSystem::expandTilde ( const std::string &  stringWithTilde)
static

Replaces "~/" with "$HOME/". Doesn't replace ~user.

Parameters
stringWithTildeA string containing tilde to expanded.
Returns
The string with tilde expanded.

Definition at line 217 of file FileSystem.cc.

217 {
218 string withoutTilde = stringWithTilde;
219 if (withoutTilde == "~" || withoutTilde.substr(0, 2) == "~/") {
220 withoutTilde.erase(0, 1);
221 withoutTilde.insert(0, FileSystem::homeDirectory());
222
223 }
224 return withoutTilde;
225}
static std::string homeDirectory()

References homeDirectory().

Referenced by ConfCommand::execute(), MachCommand::execute(), ProgCommand::execute(), GenerateProcessor::getOutputDir(), IDF::UnitImplementationLocation::hdbFile(), IDF::MachineImplementation::icDecoderPluginFile(), IDF::MachineImplementation::setICDecoderHDB(), IDF::MachineImplementation::setICDecoderPluginFile(), and ProGeOptions::validate().

Here is the call graph for this function:

◆ fileExists()

static bool FileSystem::fileExists ( const std::string  fileName)
static

Referenced by OperationIndex::addPath(), PluginTools::addSearchPath(), TestApplication::applicationPath(), ProgramImageGenerator::availableCompressors(), OperationBuilder::behaviorFile(), TestApplication::cleanupSimulation(), CompileTools::compileAsC(), Environment::confPath(), OSEdTreeView::constructTree(), ProGe::BlockSourceCopier::copyFiles(), FUGen::copyImplementation(), ProGe::BlockSourceCopier::copyProcessorSpecific(), TestApplication::correctOutput(), ProgramImageGenerator::createCompressor(), createFile(), createMauPkg(), LLVMBackend::createPlugin(), createTempDirectory(), Environment::defaultSchedulerConf(), OperationModule::definesBehavior(), CompiledSimController::deleteGeneratedFiles(), TestApplication::description(), OSEdAddModuleCmd::Do(), OSEdModifyBehaviorCmd::Do(), DSDBManager::DSDBManager(), MemWriteCommand::execute(), fileIsCreatable(), findFileInSearchPaths(), ProGeTools::findHDBPath(), Automagic::findHDBPath(), TestbenchGenerator::findVhdlTemplate(), ProGe::ProcessorGenerator::generateProcessor(), GenerateProcessor::generateProcessor(), DesignSpaceExplorer::getPlugins(), TestApplication::hasApplication(), OperationModule::hasBehaviorSource(), TestApplication::hasCleanupSimulation(), TestApplication::hasCorrectOutput(), TestApplication::hasSetupSimulation(), TestApplication::hasSimulateTTASim(), TestApplication::hasVerifySimulation(), HDB::HDBManager::HDBManager(), Environment::initialize(), SimulatorFrontend::initializeTracing(), Application::installationDir(), OperationBuilder::installDataFile(), ProGe::BlockSourceCopier::instantiateHDLTemplate(), OSEdAddModuleCmd::isEnabled(), OSEdUserManualCmd::isEnabled(), lastModificationTime(), loadDSDB(), DesignSpaceExplorer::loadExplorerPlugin(), HDB::HDBRegistry::loadFromSearchPaths(), loadInputs(), SimulatorFrontend::loadMachine(), SimulatorFrontend::loadProcessorConfiguration(), SimulatorFrontend::loadProgram(), main(), makeRelativePath(), Environment::minimalADF(), Environment::oldGccSchedulerConf(), AutoSelectImplementationsDialog::onFind(), HDBEditor::OnInit(), ProDe::OnInit(), GenerateProcessorDialog::onOK(), OperationPropertyDialog::onOpen(), ResultDialog::onOpen(), ExecutionTrace::open(), OperationSerializer::OperationSerializer(), Environment::pathTo(), OSEdInfoView::pathView(), Environment::pdfManual(), printPlugins(), PluginTools::registerModule(), HDB::HDBRegistry::removeDeadHDBPaths(), removeFileOrDirectory(), DesignSpaceExplorer::schedule(), ComponentImplementationSelector::selectComponents(), TestApplication::setupSimulation(), GhdlSimulator::simulate(), sizeInBytes(), Environment::tceCompiler(), TestApplication::TestApplication(), TTASimulatorCLI::TTASimulatorCLI(), Environment::userConfPath(), TestApplication::verifySimulation(), ProGe::NetlistBlock::write(), ProGe::VerilogNetlistWriter::writeBlock(), ProGe::VHDLNetlistWriter::writeBlock(), PlatformIntegrator::writeNewToplevel(), OperationBuilder::xmlFilePath(), and ImplementationSimulator::~ImplementationSimulator().

◆ fileExtension()

string FileSystem::fileExtension ( const std::string &  fileName)
static

Returns the file extension of an file, if anything is found.

If not extension is found, an empty string is returned.

Parameters
fileNameThe name of the file.
Returns
The file extension.

Definition at line 279 of file FileSystem.cc.

279 {
280 const Path path(fileName);
281 return boost::filesystem::extension(path);
282}

Referenced by ProgramImageGenerator::availableCompressors(), ProximOpenMachineCmd::Do(), ProDeExportCmd::Do(), GenerateProcessor::generateProcessor(), ProximMachineStateWindow::onExport(), and MDFDocument::OnOpenDocument().

◆ fileIsCreatable()

bool FileSystem::fileIsCreatable ( const std::string  fileName)
static

Tests if a file or directory can be created by user.

The file or directory can be created if:

  • it does not already exist,
  • the path where it should be created exists and is writable.
Parameters
fileNameName of the file or directory to test.
Returns
True if file or directory can be created, false otherwise.

Definition at line 123 of file FileSystem.cc.

123 {
124
125 if (fileName == "") {
126 return false;
127 }
128
129 std::string destPath = directoryOfPath(fileName);
130
131 return !fileExists(fileName) && fileExists(destPath) &&
132 fileIsWritable(destPath);
133}
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
static bool fileIsWritable(const std::string fileName)

References directoryOfPath(), fileExists(), and fileIsWritable().

Referenced by copyImageToTb(), createFile(), DSDBManager::createNew(), HDB::HDBManager::createNew(), SetHistoryFilename::execute(), main(), ProGe::VerilogNetlistWriter::writeBlock(), ProGe::VHDLNetlistWriter::writeBlock(), and XMLSerializer::writeFile().

Here is the call graph for this function:

◆ fileIsDirectory()

static bool FileSystem::fileIsDirectory ( const std::string  fileName)
static

◆ fileIsExecutable()

static bool FileSystem::fileIsExecutable ( const std::string  fileName)
static

◆ fileIsReadable()

static bool FileSystem::fileIsReadable ( const std::string  fileName)
static

◆ fileIsWritable()

static bool FileSystem::fileIsWritable ( const std::string  fileName)
static

◆ fileNameBody()

string FileSystem::fileNameBody ( const std::string &  fileName)
static

Returns the name of the file without file extension.

Parameters
fileNameThe name of the file.
Returns
The name of the file without the file extension.

Definition at line 291 of file FileSystem.cc.

291 {
292 const Path path(fileName);
293 return boost::filesystem::basename(path);
294}

Referenced by CompiledSimulation::compileAndLoadFunction(), CompiledSimCompiler::compileFile(), DesignSpaceExplorer::getPlugins(), GenerateProcessor::listICDecPluginParameters(), ProcessorImplementationWindow::onBrowseICDecPlugin(), outputFileName(), printPlugins(), ProcessorImplementationWindow::ProcessorImplementationWindow(), programDataImageFile(), and programImemImageFile().

◆ fileOfPath()

std::string FileSystem::fileOfPath ( const std::string  pathName)
static

◆ findFileInDirectoryTree()

bool FileSystem::findFileInDirectoryTree ( const Path startDirectory,
const std::string &  fileName,
Path pathFound 
)
static

Attempts to find a file from the given directory hierarchy

Parameters
startDirectoryThe directory to start the search.
fileNameThe filename to search for.
pathFoundA path to the found file.
Returns
true if the file was found. Otherwise false.

Definition at line 682 of file FileSystem.cc.

685 {
686
687 if (!exists(startDirectory)) {
688 return false;
689 }
690 directory_iterator end_itr;
691
692 for (directory_iterator itr(startDirectory); itr != end_itr; ++itr) {
693 if (is_directory(*itr)) {
694 Path p((*itr).path().string());
695 if (findFileInDirectoryTree(p, fileName, pathFound))
696 return true;
697 }
698#if BOOST_VERSION >= 103600
699 else if (itr->path().filename() == fileName)
700#else
701 else if (itr->leaf() == fileName)
702#endif
703 {
704 pathFound = Path((*itr).path().string());
705 return true;
706 }
707 }
708 return false;
709}
static bool findFileInDirectoryTree(const Path &startDirectory, const std::string &fileName, Path &pathFound)

References findFileInDirectoryTree().

Referenced by findFileInDirectoryTree().

Here is the call graph for this function:

◆ findFileInSearchPaths()

std::string FileSystem::findFileInSearchPaths ( const std::vector< std::string > &  searchPaths,
const std::string &  file 
)
static

Searches the given file in the given search paths and returns the absolute path to the file.

Parameters
searchPathsThe search paths in priority order.
fileThe file to search.
Returns
Absolute path to the file.
Exceptions
FileNotFoundIf the file is not found in the search paths.

Definition at line 562 of file FileSystem.cc.

563 {
565
566 if (isAbsolutePath(file)) {
567 if (fileExists(file)) {
568 return file;
569 } else {
570 string errorMsg = "File " + file + " not found.";
571 throw FileNotFound(__FILE__, __LINE__, __func__, errorMsg);
572 }
573 }
574
575 for (vector<string>::const_iterator iter = searchPaths.begin();
576 iter != searchPaths.end(); iter++) {
577 string path = *iter;
578 string pathToFile = path + DS + file;
579 if (fileExists(pathToFile)) {
580 return absolutePathOf(pathToFile);
581 }
582 }
583
584 string errorMsg = "File " + file + " not found in any search path.";
585 errorMsg += "Searched paths:\n";
586 for (unsigned int i = 0; i < searchPaths.size(); i++) {
587 errorMsg += searchPaths.at(i) + "\n";
588 }
589 throw FileNotFound(__FILE__, __LINE__, __func__, errorMsg);
590}

References __func__, absolutePathOf(), DIRECTORY_SEPARATOR, DS, fileExists(), and isAbsolutePath().

Referenced by IDF::MachineImplementation::checkImplFile(), ProGe::BlockSourceCopier::copyFiles(), IDF::MachineImplementation::decompressorFile(), Environment::defaultICDecoderPlugin(), FUGen::findAbsolutePath(), ProGeTools::findHDBPath(), Automagic::findHDBPath(), IDF::UnitImplementationLocation::hdbFile(), IDF::MachineImplementation::icDecoderHDB(), IDF::MachineImplementation::icDecoderPluginFile(), IDF::MachineImplementation::isLibraryImplFile(), BlockImplementationFileDialog::onOK(), IDF::MachineImplementation::setDecompressorFile(), IDF::MachineImplementation::setICDecoderHDB(), and IDF::MachineImplementation::setICDecoderPluginFile().

Here is the call graph for this function:

◆ findFromDirectory()

template<typename STLCONT >
static bool FileSystem::findFromDirectory ( const std::string &  regex,
const std::string &  directory,
STLCONT &  found 
)
static

◆ findFromDirectoryRecursive()

template<typename STLCONT >
static bool FileSystem::findFromDirectoryRecursive ( const std::string &  regex,
const std::string &  directory,
STLCONT &  found 
)
static

◆ globPath()

void FileSystem::globPath ( const std::string &  pattern,
std::vector< std::string > &  filenames 
)
static

Searches path names that matches the pattern and stores the results in string vector.

Parameters
patternThe pattern to be matched.
filenamesResults are stored here.

Definition at line 197 of file FileSystem.cc.

199 {
200
201 glob_t globbuf;
202 glob(pattern.c_str(), 0, NULL, &globbuf);
203 for (size_t i = 0; i < globbuf.gl_pathc; i++) {
204 filenames.push_back(globbuf.gl_pathv[i]);
205 }
206 // reserved memory is freed
207 globfree(&globbuf);
208}

Referenced by OperationIndex::addPath(), and CompiledSimController::reset().

◆ homeDirectory()

static std::string FileSystem::homeDirectory ( )
static

◆ isAbsolutePath()

bool FileSystem::isAbsolutePath ( const std::string &  pathName)
static

Checks if the pathName is a string representing an absolute path.

Parameters
pathNameThe investigated path.
Returns
True, if it is an absolute path, false otherwise.

Definition at line 234 of file FileSystem.cc.

234 {
235 Path path(pathName);
236 string pathString = path.string();
238 return pathString.substr(0, 1) ==
239 DS.string() ? true : false;
240}

References DIRECTORY_SEPARATOR, and DS.

Referenced by absolutePathOf(), createDirectory(), ImplementationTester::createListOfSimulationFiles(), findFileInSearchPaths(), isPath(), isRelativePath(), lastModificationTime(), PluginTools::loadSym(), main(), makeRelativePath(), ProcessorConfigurationFile::realPath(), PluginTools::registerModule(), sizeInBytes(), and PluginTools::unregisterModule().

◆ isPath()

bool FileSystem::isPath ( const std::string &  pathName)
static

Checks if the pathName is a string representing path (relative or absolute).

Parameters
pathNameThe investigated path.
Returns
True, if it is a relative path, false otherwise.

Definition at line 265 of file FileSystem.cc.

265 {
266 return (!pathName.empty() &&
267 (isRelativePath(pathName) || isAbsolutePath(pathName)));
268}

References isAbsolutePath(), and isRelativePath().

Referenced by fileOfPath().

Here is the call graph for this function:

◆ isRelativePath()

bool FileSystem::isRelativePath ( const std::string &  pathName)
static

Checks if the pathName is a string representing a relative path.

Path is relative path, if it is not absolute path and not empty string.

Parameters
pathNameThe investigated path.
Returns
True, if it is a relative path, false otherwise.

Definition at line 252 of file FileSystem.cc.

252 {
253 Path path(pathName);
254 string pathString = path.string();
255 return !isAbsolutePath(pathString) && !pathString.empty();
256}

References isAbsolutePath().

Referenced by compareFileNames(), XMLSerializer::initializeParser(), isPath(), and makeRelativePath().

Here is the call graph for this function:

◆ lastModificationTime()

std::time_t FileSystem::lastModificationTime ( const std::string &  filePath)
static

Returns last modification time of a file.

If last modification time can't be resolved, std::time_t(-1) is returned.

Parameters
filePathPath to the file.
Returns
Time of the last modification to the file.

Definition at line 352 of file FileSystem.cc.

352 {
353 if (!isAbsolutePath(filePath) || !fileExists(filePath)) {
354 return std::time_t(-1);
355 }
356
357 std::time_t lastModTime;
358 try {
359 lastModTime = boost::filesystem::last_write_time(filePath);
360 } catch (...) {
361 lastModTime = std::time_t(-1);
362 }
363
364 return lastModTime;
365}

References fileExists(), and isAbsolutePath().

Referenced by HDB::CachedHDBManager::CachedHDBManager(), and HDB::CachedHDBManager::validateCache().

Here is the call graph for this function:

◆ makeRelativePath()

bool FileSystem::makeRelativePath ( const std::vector< std::string > &  searchPaths,
const std::string &  basePath,
std::string &  toRelPath 
)
static

Creates relative path out of provided base path.

A relative path is returned if it is found under any of the search paths. Example: if base path is "/usr/foo/bar/x.hdb" and provided search path is "/usr/foo", the following relative path is formed: "bar/x.hdb".

Parameters
searchPathsRelative path to base path is searched under these.
basePathPath that needs to be changed into a relative path.
toRelPathOutputs possibly created relative path.
Returns
True if a relative path was created out of base path.

Definition at line 844 of file FileSystem.cc.

847 {
848
849 if (!isAbsolutePath(basePath)) {
850 return false;
851 }
852
853 for (unsigned int i = 0; i < searchPaths.size(); ++i) {
854 string searchPath = searchPaths.at(i);
855 string relativePath = basePath;
856
857 // try to find a relative path to the base path under search path
858 if (relativeDir(searchPath, relativePath)) {
859 string fullPath = searchPath + DIRECTORY_SEPARATOR + relativePath;
860
861 // special case: if provided search path was same as base path
862 if (relativePath == "") {
863 toRelPath = relativePath;
864 return true;
865 } else if (isRelativePath(relativePath) && fileExists(fullPath)) {
866 if (fullPath.length() == basePath.length()) {
867 toRelPath = relativePath;
868 return true;
869 }
870 }
871 }
872 }
873
874 return false;
875}
static bool relativeDir(const std::string &baseDir, std::string &toRelDir)

References DIRECTORY_SEPARATOR, fileExists(), isAbsolutePath(), isRelativePath(), and relativeDir().

Referenced by IDF::MachineImplementation::makeHDBPathRelative(), and IDF::MachineImplementation::makeImplFilesRelative().

Here is the call graph for this function:

◆ readBlockFromFile()

bool FileSystem::readBlockFromFile ( const std::string &  sourceFile,
const std::string &  blockStartRE,
const std::string &  blockEndRE,
std::string &  readBlock,
const bool  includeMatchingLines = true 
)
static

Reads a block of text from a file.

Start and end of the block are found by matching given regular expressions against whole lines in source file.

Parameters
sourceFileFile that is read.
blockStartRERegex that matches beginning of the block (one whole line) that is going to be read from the source file.
blockEndRERegex that matches end of the block (one whole line) that is going to be read from the source file.
readBlockParameter where the read block is to be stored.
includeMatchingLinesInclude lines that mark the borders of the block (lines that matched given regular expressions) to the block.
Returns
True if something was stored to readBlock string, otherwise false.

Definition at line 894 of file FileSystem.cc.

899 { //true by default
900
901 const int LINESIZE = 256;
902 char line[LINESIZE];
903
904 const boost::regex reStart(blockStartRE,
905 boost::regex::perl|boost::regex::icase);
906 const boost::regex reEnd(blockEndRE,
907 boost::regex::perl|boost::regex::icase);
908
909 string::const_iterator begin;
910 string::const_iterator end;
911 string stemp;
912 std::ifstream ifs(sourceFile.c_str(), std::ifstream::in);
913 boost::match_results<string::const_iterator> matches;
914 bool outsideBlock = true;
915 while (ifs.good()) {
916
917 ifs.getline(line, LINESIZE-1);
918 stemp = string(line);
919 begin = stemp.begin();
920 end = stemp.end();
921
922 // test if found block border
923 if (boost::regex_search(begin, end, outsideBlock ? reStart : reEnd)) {
924 if (includeMatchingLines) {
925 readBlock.append(stemp + "\n");
926 }
927 if (!outsideBlock) {
928 break;
929 } else {
930 outsideBlock = false;
931 }
932 } else if (!outsideBlock) { // if inside block
933 readBlock.append(stemp + "\n");
934 }
935 }
936
937 ifs.close();
938
939 return ifs.good();
940}

Referenced by ProGeTestBenchGenerator::createProcArchVhdl().

◆ relativeDir()

bool FileSystem::relativeDir ( const std::string &  baseDir,
std::string &  toRelDir 
)
static

Creates relative (to given base dir) directory.

Both directories given as parameter have to be absolute or false is returned.

Parameters
baseDirstring representing base directory.
toRelDirstring representing a directory which is changed to relative.
Returns
true if toRelDir is modified as relative directory otherwise false.

Definition at line 762 of file FileSystem.cc.

762 {
763
764 namespace fs = boost::filesystem;
765
766 Path basePath(baseDir);
767 Path toRelPath(toRelDir);
768
769 fs::path::iterator dstIt = basePath.begin();
770 fs::path::iterator POIt = toRelPath.begin();
771
772 fs::path::iterator dstEndIt = basePath.end();
773 fs::path::iterator POEndIt = toRelPath.end();
774
775 unsigned int sameCount = 0;
776 for (; dstIt != dstEndIt && POIt != POEndIt && *dstIt == *POIt;
777 ++dstIt, ++POIt, ++sameCount) {}
778
779 // both parameter dirs have to be absolute
780 // first path part is allways '/'
781 if (sameCount < 1) {
782 return false;
783 }
784
785 // if the to be realtive dir is under the base dir
786 if (dstIt == dstEndIt) {
787 toRelDir.clear();
788 while (POIt != POEndIt) {
789#if BOOST_FILESYSTEM_VERSION < 3
790 toRelDir.append(*POIt++);
791#else
792 std::string const tmp = POIt->string();
793 toRelDir.append(tmp);
794 POIt++;
795#endif
796 if (POIt != POEndIt) {
797 toRelDir.append(DIRECTORY_SEPARATOR);
798 }
799 }
800 return true;
801 } else { // if above
802 std::string temp;
803 while (POIt != POEndIt) {
804#if BOOST_FILESYSTEM_VERSION < 3
805 temp.append(*POIt++);
806#else
807 std::string const tmp = POIt->string();
808 POIt++;
809 temp.append(tmp);
810#endif
811 if (POIt != POEndIt) {
812 temp.append(DIRECTORY_SEPARATOR);
813 }
814 }
815
816 unsigned int diffCount = 0;
817 for (; dstIt != dstEndIt; ++dstIt, ++diffCount) {
818 }
819
820 toRelDir.clear();
821 for (unsigned int i = 0; diffCount > i; ++i) {
822 toRelDir.append("..");
823 toRelDir.append(DIRECTORY_SEPARATOR);
824 }
825 toRelDir.append(temp);
826 }
827
828 return true;
829}

References DIRECTORY_SEPARATOR.

Referenced by GenerateProcessor::generateProcessor(), makeRelativePath(), and ProGeScriptGenerator::prepareFiles().

◆ removeFileOrDirectory()

bool FileSystem::removeFileOrDirectory ( const std::string &  path)
static

Removes a file or a directory.

Parameters
pathThe path of a file or a directory.
Returns
True if directory or file is destroyed, false otherwise.

Definition at line 493 of file FileSystem.cc.

493 {
494 if (fileExists(path)) {
495 try {
496 Path tcePath(path);
497 boost::filesystem::remove_all(tcePath);
498 return true;
499 } catch (...) {
500 // failed to destroy a file or directory
501 // probably because of lack of rights.
502 return false;
503 }
504 } else {
505 return false;
506 }
507}

References fileExists().

Referenced by LLVMBackend::compile(), CompileTools::compileAsC(), CompileTools::compileAsLLVM(), ProGeScriptGenerator::createExecutableFile(), ProGeTestBenchGenerator::createFile(), CompiledSimController::deleteGeneratedFiles(), OSEdRemoveModuleCmd::Do(), BlocksConnectICCmd::Do(), VLIWConnectICCmd::Do(), OperationBuilder::installDataFile(), OSEdAddModuleCmd::isEnabled(), OSEdAddOperationCmd::isEnabled(), CallExplorerPluginWindow::onRun(), DesignSpaceExplorer::schedule(), OperationDAGDialog::updateDAG(), ImplementationTester::validateFU(), ImplementationTester::validateRF(), ImplementationSimulator::~ImplementationSimulator(), and ImplementationTester::~ImplementationTester().

Here is the call graph for this function:

◆ runShellCommand()

static bool FileSystem::runShellCommand ( const std::string  command)
static

◆ setFileExecutable()

bool FileSystem::setFileExecutable ( const std::string  fileName)
static

Grants execute rights for user to a file.

Parameters
fileNameFile whitch execute rights are to be changed.
Returns
True if operation was succesfull, otherwise false.

Definition at line 322 of file FileSystem.cc.

322 {
323 if (fileIsWritable(fileName) && fileIsReadable(fileName)) {
324 if (chmod(fileName.c_str(), S_IXUSR | S_IRUSR | S_IWUSR) != 0) {
325 return false;
326 }
327 } else if (fileIsWritable(fileName)) {
328 if (chmod(fileName.c_str(), S_IXUSR | S_IWUSR) != 0) {
329 return false;
330 }
331 } else if (fileIsReadable(fileName)) {
332 if (chmod(fileName.c_str(), S_IXUSR | S_IRUSR) != 0) {
333 return false;
334 }
335 } else {
336 if (chmod(fileName.c_str(), S_IXUSR) != 0) {
337 return false;
338 }
339 }
340 return true;
341}
static bool fileIsReadable(const std::string fileName)

References fileIsReadable(), and fileIsWritable().

Referenced by ProGeScriptGenerator::createExecutableFile(), and QuartusProjectGenerator::writeScripts().

Here is the call graph for this function:

◆ sizeInBytes()

uintmax_t FileSystem::sizeInBytes ( const std::string &  filePath)
static

Returns current size of the file in bytes.

If file size can't be resolved, static_cast<uintmax_t>(-1) is returned.

Parameters
filePathPath to the file.
Returns
Size of the file in bytes.

Definition at line 376 of file FileSystem.cc.

376 {
377 if (!isAbsolutePath(filePath) || !fileExists(filePath)) {
378 return static_cast<uintmax_t>(-1);
379 }
380
381 uintmax_t fileSize;
382 try {
383 fileSize = boost::filesystem::file_size(filePath);
384 } catch (...) {
385 fileSize = static_cast<uintmax_t>(-1);
386 }
387
388 return fileSize;
389}

References fileExists(), and isAbsolutePath().

Referenced by HDB::CachedHDBManager::CachedHDBManager(), MemWriteCommand::execute(), and HDB::CachedHDBManager::validateCache().

Here is the call graph for this function:

Member Data Documentation

◆ CURRENT_DIRECTORY

const std::string FileSystem::CURRENT_DIRECTORY = "."
static

Definition at line 190 of file FileSystem.hh.

Referenced by directoryOfPath().

◆ DIRECTORY_SEPARATOR

const std::string FileSystem::DIRECTORY_SEPARATOR
static
Initial value:
=
string(DIR_SEPARATOR)

Definition at line 189 of file FileSystem.hh.

Referenced by absolutePathOf(), AlmaIFIntegrator::addAlmaifFiles(), DSDBManager::addApplication(), AddFUFromHDBDialog::AddFUFromHDBDialog(), AddIUFromHDBDialog::AddIUFromHDBDialog(), OperationIndex::addPath(), AddRFFromHDBDialog::AddRFFromHDBDialog(), TestApplication::applicationPath(), OperationBuilder::behaviorFile(), OperationModule::behaviorModule(), OperationModule::behaviorSourceModule(), ProDe::bitmapsDirPath(), Environment::bitmapsDirPath(), OperationBuilder::buildObject(), TestApplication::cleanupSimulation(), compareFileNames(), CompiledSimulation::compileAndLoadFunction(), CompileTools::compileAsC(), CompileTools::compileAsLLVM(), CompiledSimCompiler::compileFile(), AlmaIFIntegrator::connectCoreMemories(), ProGe::BlockSourceCopier::copyFiles(), FUGen::copyImplementation(), ProGe::BlockSourceCopier::copyProcessorSpecific(), ProGe::BlockSourceCopier::copyShared(), ProGeTestBenchGenerator::copyTestBenchFiles(), TestApplication::correctOutput(), OSEdAboutDialog::createContents(), createDirectory(), ImplementationTester::createListOfSimulationFiles(), LLVMBackend::createPlugin(), ProGeTestBenchGenerator::createProcArchVhdl(), ProGeTestBenchGenerator::createTBConstFile(), createTempDirectory(), GUIOptions::createToolbar(), ImplementationSimulator::createWorkDir(), ModelsimSimulator::createWorkDir(), Environment::dataDirPath(), OperationModule::definesBehavior(), TestApplication::description(), directoryOfPath(), UserManualCmd::Do(), OSEdModifyBehaviorCmd::Do(), Environment::errorLogFilePath(), ProGeScriptGenerator::fetchFiles(), fileOfPath(), findFileInSearchPaths(), TestbenchGenerator::findVhdlTemplate(), ImplementationTester::fuTbName(), ProGeTestBenchGenerator::generate(), DefaultICDecoderGenerator::generate(), ProGeScriptGenerator::generateCompileStart(), VhdlRomGenerator::generateComponentFile(), XilinxBlockRamGenerator::generateComponentFile(), CompiledSimCodeGenerator::generateConstructorCode(), ProGe::ProcessorGenerator::generateGCUOpcodesPackage(), ProGeScriptGenerator::generateGhdlCompile(), ProGeScriptGenerator::generateGhdlSimulate(), ProGe::ProcessorGenerator::generateGlobalsPackage(), CompiledSimCodeGenerator::generateHeaderAndMainCode(), CompiledSimCodeGenerator::generateInstruction(), DefaultDecoderGenerator::generateInstructionDecoder(), AlmaIFIntegrator::generateIntegratedTestbench(), DefaultICGenerator::generateInterconnectionNetwork(), ProGeScriptGenerator::generateIverilogCompile(), ProGeScriptGenerator::generateIverilogSimulate(), CompiledSimCodeGenerator::generateMakefile(), ProGe::RV32MicroCodeGenerator::generateMap(), ProGeScriptGenerator::generateModsimCompile(), ProGeScriptGenerator::generateModsimSimulate(), ProGe::ProcessorGenerator::generateProcessor(), GenerateProcessor::generateProcessor(), ProGeScriptGenerator::generateSimulationStart(), DefaultICGenerator::generateSocket(), ProGe::RV32MicroCodeGenerator::generateWrapper(), GenerateProcessor::getOutputDir(), TestApplication::hasApplication(), DSDBManager::hasApplication(), OperationModule::hasBehaviorSource(), TestApplication::hasCleanupSimulation(), TestApplication::hasCorrectOutput(), TestApplication::hasFunctionsOfInterest(), TestApplication::hasSetupSimulation(), TestApplication::hasSimulateTTASim(), TestApplication::hasVerifySimulation(), HelpBrowser::HelpBrowser(), Environment::iconDirPath(), AlmaIFIntegrator::initAlmaifBlock(), Environment::initialize(), XMLSerializer::initializeParser(), OperationBuilder::installDataFile(), AlteraMemGenerator::instantiateAlteraTemplate(), ProGe::BlockSourceCopier::instantiateHDLTemplate(), ProGe::ProGeUI::integrateProcessor(), isAbsolutePath(), OSEdAddModuleCmd::isEnabled(), OSEdAddOperationCmd::isEnabled(), Environment::llvmtceCachePath(), Proxim::loadOptions(), SimulatorFrontend::loadProgram(), main(), makeRelativePath(), Environment::manDirPath(), Environment::minimalADF(), ProDe::OnInit(), GenerateProcessorDialog::onOK(), OperationPropertyDialog::onOpen(), OperationSerializer::OperationSerializer(), OSEdMainFrame::OSEdMainFrame(), PlatformIntegrator::outputFilePath(), Environment::pathTo(), Environment::pdfManual(), ProGeScriptGenerator::prepareFiles(), PlatformIntegrator::progeFilePath(), PlatformIntegrator::progeOutputHdlFiles(), OperationModule::propertiesModule(), ProcessorConfigurationFile::realPath(), PluginTools::registerModule(), relativeDir(), CompiledSimController::reset(), ImplementationTester::rfTbName(), DesignSpaceExplorer::schedule(), Environment::schemaDirPath(), ComponentImplementationSelector::selectComponents(), TestApplication::setupSimulation(), TestApplication::simulateTTASim(), PlatformIntegrator::tbFilePath(), MemoryGenerator::templatePath(), TestApplication::TestApplication(), AddIUFromHDBDialog::TransferDataToWindow(), OSEdUserManualCmd::userManual(), TestApplication::verifySimulation(), ProGe::LoopBufferBlock::write(), ProGe::NetlistBlock::write(), ProGe::VerilogNetlistWriter::writeBlock(), ProGe::VHDLNetlistWriter::writeBlock(), DefaultDecoderGenerator::writeInstructionDecoder(), DefaultICGenerator::writeInterconnectionNetwork(), ProGe::VerilogNetlistWriter::writeNetlistParameterPackage(), ProGe::VHDLNetlistWriter::writeNetlistParameterPackage(), and OperationBuilder::xmlFilePath().

◆ STRING_WILD_CARD

const std::string FileSystem::STRING_WILD_CARD = "*"
static

Definition at line 191 of file FileSystem.hh.

Referenced by OperationIndex::addPath().


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