Static Public Member Functions | List of all members
openfluid::tools::Filesystem Class Reference

#include <tools/Filesystem.hpp>

Static Public Member Functions

static std::string filename (const std::string &Path)
 
static std::string basename (const std::string &Path)
 
static std::string dirname (const std::string &Path)
 
static std::string extension (const std::string &Path)
 
static std::string currentPath ()
 
static bool isDirectory (const std::string &Path)
 
static bool isFile (const std::string &Path)
 
static bool makeDirectory (const std::string &Path)
 
static bool removeDirectory (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 bool removeFile (const std::string &Path)
 
static bool copyFile (const std::string &SrcPath, const std::string &DestPath)
 
static bool copyDirectory (const std::string &SrcPath, const std::string &DestPath, const bool DontCopyDotDirs=false)
 

Member Function Documentation

static std::string openfluid::tools::Filesystem::basename ( const std::string &  Path)
static

Returns the complete base name of the file in the given path

name = openfluid::tools::Filesystem::basename("/tmp/archive.tar.gz")
// name = archive.tar
Parameters
[in]Paththe given path
Returns
the base name of the file
static bool openfluid::tools::Filesystem::copyDirectory ( const std::string &  SrcPath,
const std::string &  DestPath,
const bool  DontCopyDotDirs = false 
)
static

Recursively copies a directory from source to destination.

Parameters
[in]SrcPaththe source path
[in]DestPaththe destination path
[in]DontCopyDotDirsif set to true, it ignores the directories beginning with a dot ('.'). Default is false
Returns
true if the directory was successfully copied, false otherwise
static bool openfluid::tools::Filesystem::copyFile ( const std::string &  SrcPath,
const std::string &  DestPath 
)
static

Copies a file from source to destination.

Parameters
[in]SrcPaththe source path
[in]DestPaththe destination path
Returns
true if the file was successfully copied, false otherwise
static std::string openfluid::tools::Filesystem::currentPath ( )
static

Returns the current application path

Returns
the current path
static std::string openfluid::tools::Filesystem::dirname ( const std::string &  Path)
static

Returns the directory name (parent path) of the given path

name = openfluid::tools::Filesystem::dirname("/tmp/archive.tar.gz")
// name = /tmp
Parameters
[in]Paththe given path
Returns
the directory name
static std::string openfluid::tools::Filesystem::extension ( const std::string &  Path)
static

Returns the extension of the file of the given path

name = openfluid::tools::Filesystem::extension("/tmp/archive.tar.gz")
// name = gz
Parameters
[in]Paththe given path
Returns
the extension
static std::string openfluid::tools::Filesystem::filename ( const std::string &  Path)
static

Returns the name of the file in the given path

name = openfluid::tools::Filesystem::filename("/tmp/archive.tar.gz")
// name = archive.tar.gz
Parameters
[in]Paththe given path
Returns
the filename
static bool openfluid::tools::Filesystem::isDirectory ( const std::string &  Path)
static

Returns true if the given path is a directory

Parameters
[in]Paththe given path
Returns
true or false
static bool openfluid::tools::Filesystem::isFile ( const std::string &  Path)
static

Returns true if the given path is a file or a valid symbolic link

Parameters
[in]Paththe given path
Returns
true or false
static bool openfluid::tools::Filesystem::makeDirectory ( const std::string &  Path)
static

Creates the directory of the given path. It creates all parent directories necessary to create the directory. If the directory already exists, it does nothing.

Parameters
[in]Paththe given path
Returns
true if the directory was successfully created, false otherwise
static std::string openfluid::tools::Filesystem::makeUniqueFile ( const std::string &  Path,
const std::string &  FileName 
)
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.

Parameters
[in]Paththe given path for the file
[in]FileNamethe file name used to make a unique one
Returns
the full path of the created unique file
static std::string openfluid::tools::Filesystem::makeUniqueSubdirectory ( const std::string &  Path,
const std::string &  SubdirName 
)
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.

Parameters
[in]Paththe given path
[in]SubdirNamethe given path
Returns
the full path of the created unique subdirectory
static bool openfluid::tools::Filesystem::removeDirectory ( const std::string &  Path)
static

Removes the directory of the given path. It recursively deletes all contents of the directory.

Parameters
[in]Paththe given path
Returns
true if the directory was successfully deleted, false otherwise
static bool openfluid::tools::Filesystem::removeFile ( const std::string &  Path)
static

Removes the file of the given path.

Parameters
[in]Paththe given path
Returns
true if the file was successfully deleted, false otherwise

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