Go to the documentation of this file.
35 #ifndef TTA_FILESYSTEM_HH
36 #define TTA_FILESYSTEM_HH
41 #include <boost/version.hpp>
57 #if BOOST_VERSION < 104400
58 #define BOOST_FILESYSTEM_VERSION 2
60 #define BOOST_FILESYSTEM_VERSION 3
65 #if BOOST_VERSION <= 105100
66 #define BOOST_NO_SCOPED_ENUMS
68 #define BOOST_NO_CXX11_SCOPED_ENUMS
71 #include <boost/filesystem/path.hpp>
90 static bool fileExists(
const std::string fileName);
99 static std::string
fileOfPath(
const std::string pathName);
102 static bool isPath(
const std::string& pathName);
103 static std::string
fileExtension(
const std::string& fileName);
104 static std::string
fileNameBody(
const std::string& fileName);
117 static uintmax_t
sizeInBytes(
const std::string& filePath);
123 static void globPath(
const std::string& pattern,
124 std::vector<std::string>& filenames);
125 static std::string
expandTilde(
const std::string& stringWithTilde);
129 const std::string& path=
"/tmp",
130 const std::string& tempDirPrefix =
"tmp_tce_");
131 static bool createFile(
const std::string& file);
134 static void copy(
const std::string& source,
const std::string& target);
137 const std::vector<std::string>& searchPaths,
const std::string& file);
140 const std::string& directory,
const bool absolutePaths =
true);
143 const std::string& directory);
146 const Path& startDirectory,
147 const std::string& fileName,
150 template <
typename STLCONT>
152 const std::string& regex,
const std::string& directory, STLCONT& found);
154 template <
typename STLCONT>
156 const std::string& regex,
157 const std::string& directory,
161 const std::string& first,
162 const std::string& second,
163 const std::string& rootDirectory);
166 const std::string& baseDir,
167 std::string& toRelDir);
170 const std::vector<std::string>& searchPaths,
171 const std::string& basePath,
172 std::string& toRelPath);
175 const std::string& sourceFile,
176 const std::string& blockStartRE,
177 const std::string& blockEndRE,
178 std::string& readBlock,
179 const bool includeMatchingLines =
true);
182 const std::string& targetFile,
183 const std::string& ARStartRE,
184 const std::string& writeToFile,
185 const std::string& AREndRE =
"",
186 const bool discardBlockBorder =
"true");
187 static int countLines(
const std::string& filepath);
197 class Path :
public boost::filesystem::path {
200 explicit Path(
const boost::filesystem::path& path);
202 operator std::string()
const;
204 const char*
c_str()
const;
Path operator/(const Path &path, const std::string &fileOrDir)
static bool removeFileOrDirectory(const std::string &path)
static bool createDirectory(const std::string &path)
static bool setFileExecutable(const std::string fileName)
static bool isRelativePath(const std::string &pathName)
static std::vector< std::string > directorySubTrees(const std::string &directory)
static void globPath(const std::string &pattern, std::vector< std::string > &filenames)
static bool findFromDirectory(const std::string ®ex, const std::string &directory, STLCONT &found)
static std::string absolutePathOf(const std::string &pathName)
static bool relativeDir(const std::string &baseDir, std::string &toRelDir)
static std::string fileOfPath(const std::string pathName)
static bool fileIsCreatable(const std::string fileName)
const char * c_str() const
static bool makeRelativePath(const std::vector< std::string > &searchPaths, const std::string &basePath, std::string &toRelPath)
static bool fileIsDirectory(const std::string fileName)
static std::string homeDirectory()
static bool fileIsWritable(const std::string fileName)
static std::time_t lastModificationTime(const std::string &filePath)
static std::string fileExtension(const std::string &fileName)
static bool findFromDirectoryRecursive(const std::string ®ex, const std::string &directory, STLCONT &found)
static std::string directoryOfPath(const std::string fileName)
static void copy(const std::string &source, const std::string &target)
static bool isPath(const std::string &pathName)
static std::string expandTilde(const std::string &stringWithTilde)
static uintmax_t sizeInBytes(const std::string &filePath)
static bool createFile(const std::string &file)
static bool readBlockFromFile(const std::string &sourceFile, const std::string &blockStartRE, const std::string &blockEndRE, std::string &readBlock, const bool includeMatchingLines=true)
static const std::string DIRECTORY_SEPARATOR
static const std::string CURRENT_DIRECTORY
static bool changeWorkingDir(const std::string &path)
Path & operator=(const boost::filesystem::path &pathName)
static int countLines(const std::string &filepath)
static bool fileExists(const std::string fileName)
static bool appendReplaceFile(const std::string &targetFile, const std::string &ARStartRE, const std::string &writeToFile, const std::string &AREndRE="", const bool discardBlockBorder="true")
static bool fileIsExecutable(const std::string fileName)
static std::string currentWorkingDir()
static const std::string STRING_WILD_CARD
static bool runShellCommand(const std::string command)
static bool fileIsReadable(const std::string fileName)
static std::string fileNameBody(const std::string &fileName)
static std::string findFileInSearchPaths(const std::vector< std::string > &searchPaths, const std::string &file)
static bool compareFileNames(const std::string &first, const std::string &second, const std::string &rootDirectory)
static bool isAbsolutePath(const std::string &pathName)
static std::string createTempDirectory(const std::string &path="/tmp", const std::string &tempDirPrefix="tmp_tce_")
static std::vector< std::string > directoryContents(const std::string &directory, const bool absolutePaths=true)
static bool findFileInDirectoryTree(const Path &startDirectory, const std::string &fileName, Path &pathFound)