iRoCS Toolbox  1.1.0
Static Public Member Functions
BaseFile Class Reference

#include <BaseFile.hh>

Collaboration diagram for BaseFile:

Static Public Member Functions

static std::string BaseName (const std::string &aPathName)
 BaseName returns the file name component of the path. More...
 
static std::string BaseNamePath (const std::string &aPathName)
 BaseNamePath returns the fully qualified path to the file. More...
 
static std::string BeautifyFilePath (const std::string &aPath)
 BeautifyFilePath sanitizes a path to a file or directory. More...
 
static bool Copy (const std::string &aOldName, const std::string &aNewName)
 Copy copies a file or directory. More...
 
static bool DirectoryCreate (const std::string &aPathName)
 DirectoryCreate cretaes a directory at the specified path. More...
 
static std::string DirName (const std::string &aPathName)
 DirName returns the directory name component ofthe path. More...
 
static bool Exists (const std::string &aPathName)
 Exists tests for existance of a file or directory using the stat() function call (which succeeds even if no read permissions are available. More...
 
static std::string FindUniqueUnexistingName (std::string const &aBaseName, char aPattern)
 Generates a new unique file name using pattern. More...
 
static bool IsDirectory (const std::string &aPathName)
 IsDirectory tests whether a file system entry is a directory or not. More...
 
static bool IsFile (const std::string &aPathName)
 IsFile tests whether a file system entry is a normal file or not. More...
 
static bool IsLink (const std::string &aPathName)
 IsLink tests whether a file system entry is a symlink or not. More...
 
static bool ListDir (const std::string &aInputDir, std::vector< std::string > &aFiles, const std::string &aPattern)
 Lists the files in a directory. More...
 
static bool Move (const std::string &aOldName, const std::string &aNewName)
 Move renames a file or directory. More...
 
static bool Remove (const std::string &aPathName)
 Remove deletes a file or directory. More...
 

Detailed Description

Definition at line 48 of file BaseFile.hh.

Member Function Documentation

◆ BaseName()

static std::string BaseFile::BaseName ( const std::string &  aPathName)
static

BaseName returns the file name component of the path.

Note that it will return the original name, if no '/' character is found in the path name.

Returns
file name

◆ DirName()

static std::string BaseFile::DirName ( const std::string &  aPathName)
static

DirName returns the directory name component ofthe path.

Note that it will return an empty string if no '/' character is found in the path name.

Returns
directory name

◆ BaseNamePath()

static std::string BaseFile::BaseNamePath ( const std::string &  aPathName)
static

BaseNamePath returns the fully qualified path to the file.

It expands all symbolic links and resolves references to /./, /../ and extra '/' characters, to produce a canonicalized absolute pathname.

Todo:
Current implementation does not work on Windows
Returns
string the path to the file

◆ Exists()

static bool BaseFile::Exists ( const std::string &  aPathName)
static

Exists tests for existance of a file or directory using the stat() function call (which succeeds even if no read permissions are available.

Parameters
aPathNamethe path to the file/directory to check
Returns
bool returns true if the file or directory exists, false otherwise.

◆ IsFile()

static bool BaseFile::IsFile ( const std::string &  aPathName)
static

IsFile tests whether a file system entry is a normal file or not.

Parameters
aPathNamethe path to the file/directory to check
Returns
bool returns true if the entry is a normal file, false otherwise.

◆ IsLink()

static bool BaseFile::IsLink ( const std::string &  aPathName)
static

IsLink tests whether a file system entry is a symlink or not.

Parameters
aPathNamethe path to the file/directory to check
Returns
bool returns true if the entry is a symbolic link, false otherwise.

◆ IsDirectory()

static bool BaseFile::IsDirectory ( const std::string &  aPathName)
static

IsDirectory tests whether a file system entry is a directory or not.

Parameters
aPathNamethe path to the file/directory to check
Returns
bool returns true if the entry is a directory, false otherwise.

◆ DirectoryCreate()

static bool BaseFile::DirectoryCreate ( const std::string &  aPathName)
static

DirectoryCreate cretaes a directory at the specified path.

If the directory already exists, nothing is done.

Parameters
aPathNamethe path to the directory to create.
Returns
bool returns true if the directory was created or exists already, false otherwise.

◆ ListDir()

static bool BaseFile::ListDir ( const std::string &  aInputDir,
std::vector< std::string > &  aFiles,
const std::string &  aPattern 
)
static

Lists the files in a directory.

Parameters
aInputDirthe path to the directory
aFilesa vector of fully qualified entries
aPattern
Returns
bool returns true if the file or directory was successfully listed, false otherwise.

◆ Remove()

static bool BaseFile::Remove ( const std::string &  aPathName)
static

Remove deletes a file or directory.

Parameters
aPathNamethe path to the file/directory to remove
Returns
bool returns true if the file or directory was successfully removed, false otherwise.

◆ Move()

static bool BaseFile::Move ( const std::string &  aOldName,
const std::string &  aNewName 
)
static

Move renames a file or directory.

Parameters
aOldNamethe path to the file/directory to rename
aNewNamethe path to the new file/directory name
Returns
bool returns true if the file or directory was successfully renamed, false otherwise.

◆ Copy()

static bool BaseFile::Copy ( const std::string &  aOldName,
const std::string &  aNewName 
)
static

Copy copies a file or directory.

Parameters
aOldNamethe path to the file/directory to rename
aNewNamethe path to the new file/directory name
Returns
bool returns true if the file or directory was successfully copied, false otherwise.

◆ FindUniqueUnexistingName()

static std::string BaseFile::FindUniqueUnexistingName ( std::string const &  aBaseName,
char  aPattern 
)
static

Generates a new unique file name using pattern.

Parameters
aBaseNamePrefix
aPatternPattern
Returns
A new filename

◆ BeautifyFilePath()

static std::string BaseFile::BeautifyFilePath ( const std::string &  aPath)
static

BeautifyFilePath sanitizes a path to a file or directory.

It replaces duplicate slashes with signle slashes, uses forward slashes where possible, and other neat things.

Parameters
aPaththe path to the file/directory to beautify
Returns
the beautified path

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