Documentation for OpenFLUID
2.2.0
|
#include <tools/Filesystem.hpp>
Public Member Functions | |
Filesystem ()=delete | |
Static Public Member Functions | |
constexpr static char | pathsListSeparator () noexcept |
constexpr static char | pathSeparator () noexcept |
static std::string | joinPath (const std::vector< std::string > &PathParts) |
static std::string | homePath () |
static std::string | tempPath () |
static std::string | filename (const std::string &Path) |
static std::string | dirname (const std::string &Path) |
static std::string | basename (const std::string &Path) |
static std::string | minimalBasename (const std::string &Path) |
static std::string | extension (const std::string &Path) |
static std::string | completeExtension (const std::string &Path) |
static std::string | currentPath () |
static std::string | absolutePath (const std::string &Path) |
static std::string | makeUniqueSubdirectory (const std::string &Path, const std::string &SubdirName) |
static std::string | makeUniqueFile (const std::string &Path, const std::string &FileName) |
static std::string | readFile (const openfluid::tools::FilesystemPath &FileObj) |
static void | writeFile (const std::string &Content, const openfluid::tools::FilesystemPath &FileObj) |
static void | appendToFile (const std::string &Content, const openfluid::tools::FilesystemPath &FileObj) |
static bool | copyFile (const std::string &SrcPath, const std::string &DestPath) |
static bool | renameFile (const std::string &OriginalPath, const std::string &NewPath) |
static bool | copyDirectory (const std::string &SrcPath, const std::string &DestPath, bool WithBaseDir=false, bool RemoveExisting=false) |
static bool | copyDirectoryContent (const std::filesystem::path &SrcPath, const std::filesystem::path &DestPath) |
static bool | emptyDirectory (const std::string &Path, const std::vector< std::string > &PathsToExlude={}) |
static std::vector< std::string > | findFiles (const std::string &Path, bool WithPath=false, const std::string &Pattern="") |
static std::vector< std::string > | findDirectories (const std::string &Path, bool WithPath=false, const std::string &Pattern="") |
static std::vector< std::string > | findFilesByExtension (const std::string &Path, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false) |
static std::vector< std::string > | findFilesBySuffixAndExtension (const std::string &Path, const std::string &Suffix, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false) |
|
delete |
|
static |
Returns the absolute path of the given path. If the given path is already an absolute path, it is returned as-is.
[in] | Path | the path to make absolute |
|
static |
Appends content on a new line into a file
[in] | Content | the content to append |
[in] | FileObj | the given path for the file |
|
static |
|
static |
|
static |
Recursively copies a directory from source to destination.
[in] | SrcPath | the source path |
[in] | DestPath | the destination path |
[in] | WithBaseDir | if true, the source directory is created in the destination dir as an intermdiate directory (e.g. if the content of /my/path/first is copied into /my/path/second, the content will actually be copied into /my/path/second/first) |
[in] | RemoveExisting | if true, the destination directory is deleted if it already exists |
|
static |
Recursively copies content of a directory from source to destination, handling windows bug with regular dir copy.
[in] | SrcPath | the source path |
[in] | DestPath | the destination path |
|
static |
Copies a file from source to destination.
[in] | SrcPath | the source path |
[in] | DestPath | the destination path |
|
static |
Returns the current path
|
static |
|
static |
Recursively removes all files and directories contained in the given directory. It deletes the directory and recreates it.
[in] | Path | the directory to empty |
[in] | PathsToExlude | Paths that are not deleted. |
|
static |
|
static |
|
static |
Gets the list of directories found in the specified directory
[in] | Path | the directory to explore |
[in] | WithPath | return full path if true, directory name only otherwise |
[in] | Pattern | an optional pattern to filter the directories to find |
|
static |
Gets the list of files found in the specified directory
[in] | Path | the directory to explore |
[in] | WithPath | return full path if true, directory name only otherwise |
[in] | Pattern | an optional pattern to filter the files to find |
|
static |
Gets the list of files with specified extension contained in the specified directory
[in] | Path | the directory to explore |
[in] | Ext | the file extension |
[in] | WithPath | return full path with file name if true, file name only otherwise |
[in] | ExtIncludeDot | if true, the given extension through Ext parameter is suffixed by a dot |
|
static |
Get list of files with specified extension contained in the specified dir
[in] | Path | the directory to explore |
[in] | Ext | the file extension |
[in] | Suffix | the file suffix |
[in] | WithPath | return full path with file name if true, file name only otherwise |
[in] | ExtIncludeDot | if true, the given extension through Ext parameter is suffixed by a dot |
|
static |
Returns the user home path (e.g. '/home/username' on Linux, 'C:/Users/username' on Windows, ...)
|
static |
Returns a joined path string from a vector of path parts, using the '/' separator
[in] | PathParts | a vector of path parts |
|
static |
Creates a unique file in the given path, using the given File name and extension as prefix and suffix. If the file already exists, it adds an incremental part to the file name. If the Path does not exists, it creates all needed parent directories.
[in] | Path | the given path for the file |
[in] | FileName | the file name used to make a unique one |
|
static |
Creates a unique subdirectory in the given path, using the given subdirectory name as a prefix. If the subdirectory already exists, it adds an incremental suffix to the subdirectory name. It creates all parent directories necessary to create the subdirectory.
[in] | Path | the given path |
[in] | SubdirName | the given path |
|
static |
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
static |
Reads the content of a file
[in] | FileObj | the given path for the file |
|
static |
Rename a file.
[in] | OriginalPath | the original file path |
[in] | NewPath | the new file path |
|
static |
Returns the system path for temporary files (e.g. '/tmp' on Linux, ...)
|
static |
Writes content into a file
[in] | Content | the content to write |
[in] | FileObj | the given path for the file |