Biorbd
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
biorbd::utils::Path Class Reference

Collection of methods to manipulate path. More...

#include <Path.h>

Public Member Functions

 Path ()
 Construct path.
 
 Path (const char *path)
 Construct path. More...
 
 Path (const biorbd::utils::String &path)
 Construct path. More...
 
 Path (const std::basic_string< char > &path)
 Construct path. More...
 
biorbd::utils::Path DeepCopy () const
 Deep copy of path. More...
 
void DeepCopy (const biorbd::utils::Path &other)
 Deep copy of path from another path. More...
 
bool isFileExist () const
 Test if file exist on the computer. More...
 
bool isFileReadable () const
 Test if file exist on the computer and is accessible. More...
 
bool isFolderExist () const
 Test if folder exists on the computer. More...
 
void createFolder () const
 To create folder on the computer.
 
biorbd::utils::String relativePath () const
 Return relative path to current working directory. More...
 
biorbd::utils::String relativePath (const biorbd::utils::String &relativeTo) const
 Return relative path to the specified folder. More...
 
biorbd::utils::String absoluteFolder () const
 Return the absolute folder relative to root. More...
 
biorbd::utils::String absolutePath () const
 Return the absolute path relative to root. More...
 
const biorbd::utils::StringoriginalPath () const
 Return original path as it was at constructor time. More...
 
const biorbd::utils::Stringfolder () const
 Return the folder of the file. More...
 
void setFilename (const biorbd::utils::String &name)
 Set the filename. More...
 
const biorbd::utils::Stringfilename () const
 Return the filename. More...
 
void setExtension (const biorbd::utils::String &ext)
 Set the extension. More...
 
const biorbd::utils::Stringextension () const
 Return the extension of the file. More...
 

Static Public Member Functions

static void parseFileName (const biorbd::utils::String &path, biorbd::utils::String &folder, biorbd::utils::String &filename, biorbd::utils::String &ext)
 Parse a path in folder, filename and extension. More...
 
static bool isFileExist (const biorbd::utils::Path &path)
 Test if file exist on the computer. More...
 
static bool isFileExist (const biorbd::utils::String &path)
 Test if file exist on the computer. More...
 
static bool isFolderExist (const biorbd::utils::Path &path)
 Test if folder exists on the computer. More...
 
static bool isFolderExist (const biorbd::utils::String &path)
 Test if folder exists on the computer. More...
 
static biorbd::utils::String currentDir ()
 
static biorbd::utils::String relativePath (const biorbd::utils::Path &path, const biorbd::utils::String &relativeTo)
 Return relative path of a specified path to the specified folder. More...
 
static biorbd::utils::String absoluteFolder (const biorbd::utils::Path &path)
 Return the absolute path relative to root. More...
 
static biorbd::utils::String toUnixFormat (const biorbd::utils::String &path)
 Return the path to Unix format. More...
 
static biorbd::utils::String toWindowsFormat (const biorbd::utils::String &path)
 Return the path to Windows format. More...
 

Protected Member Functions

void setIsFolderAbsolute ()
 Set if folder is absolute.
 

Protected Attributes

std::shared_ptr< biorbd::utils::Stringm_originalPath
 The original path at construction time.
 
std::shared_ptr< biorbd::utils::Stringm_folder
 The folder.
 
std::shared_ptr< bool > m_isFolderAbsolute
 If folder is absolute.
 
std::shared_ptr< biorbd::utils::Stringm_filename
 The filename.
 
std::shared_ptr< biorbd::utils::Stringm_extension
 The extension.
 

Detailed Description

Collection of methods to manipulate path.

Definition at line 16 of file Path.h.

Constructor & Destructor Documentation

◆ Path() [1/3]

biorbd::utils::Path::Path ( const char *  path)

Construct path.

Parameters
pathThe path in char format

Definition at line 29 of file Path.cpp.

◆ Path() [2/3]

biorbd::utils::Path::Path ( const biorbd::utils::String path)

Construct path.

Parameters
pathThe path in string format

Definition at line 41 of file Path.cpp.

◆ Path() [3/3]

biorbd::utils::Path::Path ( const std::basic_string< char > &  path)

Construct path.

Parameters
pathThe path in vector char format

Definition at line 53 of file Path.cpp.

Member Function Documentation

◆ absoluteFolder() [1/2]

biorbd::utils::String biorbd::utils::Path::absoluteFolder ( ) const

Return the absolute folder relative to root.

Returns
The absolute folder relative to root

Definition at line 282 of file Path.cpp.

◆ absoluteFolder() [2/2]

biorbd::utils::String biorbd::utils::Path::absoluteFolder ( const biorbd::utils::Path path)
static

Return the absolute path relative to root.

Parameters
pathThe path to find the path
Returns
The absolute folder

On Windows, the current implementation only works if the file is on the C drive.

Definition at line 258 of file Path.cpp.

◆ absolutePath()

biorbd::utils::String biorbd::utils::Path::absolutePath ( ) const

Return the absolute path relative to root.

Returns
The absolute path relative to root

Definition at line 290 of file Path.cpp.

◆ currentDir()

biorbd::utils::String biorbd::utils::Path::currentDir ( )
static

/brief Return current directory

Returns
Teh current directory

Definition at line 391 of file Path.cpp.

◆ DeepCopy() [1/2]

biorbd::utils::Path biorbd::utils::Path::DeepCopy ( ) const

Deep copy of path.

Returns
A deep copy of path

Definition at line 65 of file Path.cpp.

◆ DeepCopy() [2/2]

void biorbd::utils::Path::DeepCopy ( const biorbd::utils::Path other)

Deep copy of path from another path.

Parameters
otherThe path to copy

Definition at line 72 of file Path.cpp.

◆ extension()

const biorbd::utils::String & biorbd::utils::Path::extension ( ) const

Return the extension of the file.

Returns
The extension of the file

Definition at line 363 of file Path.cpp.

◆ filename()

const biorbd::utils::String & biorbd::utils::Path::filename ( ) const

Return the filename.

Returns
The filename

Definition at line 352 of file Path.cpp.

◆ folder()

const biorbd::utils::String & biorbd::utils::Path::folder ( ) const

Return the folder of the file.

Returns
The folder of the file

Definition at line 341 of file Path.cpp.

◆ isFileExist() [1/3]

bool biorbd::utils::Path::isFileExist ( ) const

Test if file exist on the computer.

Returns
If file exist on the computer

Definition at line 82 of file Path.cpp.

◆ isFileExist() [2/3]

bool biorbd::utils::Path::isFileExist ( const biorbd::utils::Path path)
static

Test if file exist on the computer.

Parameters
pathThe path of the file
Returns
If file exist on the computer

Definition at line 86 of file Path.cpp.

◆ isFileExist() [3/3]

bool biorbd::utils::Path::isFileExist ( const biorbd::utils::String path)
static

Test if file exist on the computer.

Parameters
pathThe path of the file
Returns
If file exist on the computer

Definition at line 91 of file Path.cpp.

◆ isFileReadable()

bool biorbd::utils::Path::isFileReadable ( ) const

Test if file exist on the computer and is accessible.

Returns
If file is readable

Definition at line 108 of file Path.cpp.

◆ isFolderExist() [1/3]

bool biorbd::utils::Path::isFolderExist ( ) const

Test if folder exists on the computer.

Returns
If folder exists

Definition at line 122 of file Path.cpp.

◆ isFolderExist() [2/3]

bool biorbd::utils::Path::isFolderExist ( const biorbd::utils::Path path)
static

Test if folder exists on the computer.

Parameters
pathThe path in which to test if the folder exists
Returns
If folder exists

Definition at line 127 of file Path.cpp.

◆ isFolderExist() [3/3]

bool biorbd::utils::Path::isFolderExist ( const biorbd::utils::String path)
static

Test if folder exists on the computer.

Parameters
pathThe path in which to test if the folder exists
Returns
If folder exists

Definition at line 133 of file Path.cpp.

◆ originalPath()

const biorbd::utils::String & biorbd::utils::Path::originalPath ( ) const

Return original path as it was at constructor time.

Returns
The original path

Definition at line 336 of file Path.cpp.

◆ parseFileName()

void biorbd::utils::Path::parseFileName ( const biorbd::utils::String path,
biorbd::utils::String folder,
biorbd::utils::String filename,
biorbd::utils::String ext 
)
static

Parse a path in folder, filename and extension.

Parameters
pathThe path to parse
folderThe folder of the file
filenameThe file name
extThe extension of the file

Definition at line 158 of file Path.cpp.

◆ relativePath() [1/3]

biorbd::utils::String biorbd::utils::Path::relativePath ( ) const

Return relative path to current working directory.

Returns
The relative path to curent working directory

Definition at line 190 of file Path.cpp.

◆ relativePath() [2/3]

biorbd::utils::String biorbd::utils::Path::relativePath ( const biorbd::utils::Path path,
const biorbd::utils::String relativeTo 
)
static

Return relative path of a specified path to the specified folder.

Parameters
pathThe path to find the relative path from
relativeToRelative to that path
Returns
The relative path

Definition at line 200 of file Path.cpp.

◆ relativePath() [3/3]

biorbd::utils::String biorbd::utils::Path::relativePath ( const biorbd::utils::String relativeTo) const

Return relative path to the specified folder.

Parameters
relativeToRelative to that path
Returns
The relative path

Definition at line 194 of file Path.cpp.

◆ setExtension()

void biorbd::utils::Path::setExtension ( const biorbd::utils::String ext)

Set the extension.

Parameters
extThe extension

Definition at line 357 of file Path.cpp.

◆ setFilename()

void biorbd::utils::Path::setFilename ( const biorbd::utils::String name)

Set the filename.

Parameters
nameThe filename

Definition at line 346 of file Path.cpp.

◆ toUnixFormat()

biorbd::utils::String biorbd::utils::Path::toUnixFormat ( const biorbd::utils::String path)
static

Return the path to Unix format.

Parameters
pathThe path to convert
Returns
The path in Unix format

Definition at line 301 of file Path.cpp.

◆ toWindowsFormat()

biorbd::utils::String biorbd::utils::Path::toWindowsFormat ( const biorbd::utils::String path)
static

Return the path to Windows format.

Parameters
pathThe path to convert
Returns
The path in Windows format

Definition at line 324 of file Path.cpp.


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