Biorbd Release_1.13.0
Loading...
Searching...
No Matches
BIORBD_NAMESPACE::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.
 Path (const String &path)
 Construct path.
 Path (const std::basic_string< char > &path)
 Construct path.
Path DeepCopy () const
 Deep copy of path.
void DeepCopy (const Path &other)
 Deep copy of path from another path.
bool isFileExist () const
 Test if file exist on the computer.
bool isFileReadable () const
 Test if file exist on the computer and is accessible.
bool isFolderExist () const
 Test if folder exists on the computer.
void createFolder () const
 To create folder on the computer.
String relativePath () const
 Return relative path to current working directory.
String relativePath (const String &relativeTo) const
 Return relative path to the specified folder.
String absoluteFolder () const
 Return the absolute folder relative to root.
String absolutePath () const
 Return the absolute path relative to root.
const String & originalPath () const
 Return original path as it was at constructor time.
void setFolder (const String &folder)
 Set the folder of the file.
const String & folder () const
 Return the folder of the file.
void setFilename (const String &name)
 Set the filename.
const String & filename () const
 Return the filename.
void setExtension (const String &ext)
 Set the extension.
const String & extension () const
 Return the extension of the file.

Static Public Member Functions

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

Protected Member Functions

void setIsFolderAbsolute ()
 Set if folder is absolute.

Protected Attributes

std::shared_ptr< String > m_originalPath
 The original path at construction time.
std::shared_ptr< String > m_folder
 The folder.
std::shared_ptr< bool > m_isFolderAbsolute
 If folder is absolute.
std::shared_ptr< String > m_filename
 The filename.
std::shared_ptr< String > m_extension
 The extension.

Detailed Description

Collection of methods to manipulate path.

Definition at line 16 of file Path.h.

Constructor & Destructor Documentation

◆ Path() [1/4]

utils::Path::Path ( )

Construct path.

Definition at line 22 of file Path.cpp.

◆ Path() [2/4]

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

Construct path.

Parameters
pathThe path in char format

Definition at line 29 of file Path.cpp.

◆ Path() [3/4]

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

Construct path.

Parameters
pathThe path in string format

Definition at line 39 of file Path.cpp.

◆ Path() [4/4]

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

Construct path.

Parameters
pathThe path in vector char format

Definition at line 49 of file Path.cpp.

Member Function Documentation

◆ absoluteFolder() [1/2]

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

Return the absolute folder relative to root.

Returns
The absolute folder relative to root

Definition at line 257 of file Path.cpp.

◆ absoluteFolder() [2/2]

utils::String utils::Path::absoluteFolder ( const 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 235 of file Path.cpp.

◆ absolutePath()

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

Return the absolute path relative to root.

Returns
The absolute path relative to root

Definition at line 265 of file Path.cpp.

◆ createFolder()

void utils::Path::createFolder ( ) const

To create folder on the computer.

Definition at line 361 of file Path.cpp.

◆ currentDir()

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

/brief Return current directory

Returns
Teh current directory

Definition at line 349 of file Path.cpp.

◆ DeepCopy() [1/2]

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

Deep copy of path.

Returns
A deep copy of path

Definition at line 59 of file Path.cpp.

◆ DeepCopy() [2/2]

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

Deep copy of path from another path.

Parameters
otherThe path to copy

Definition at line 65 of file Path.cpp.

◆ extension()

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

Return the extension of the file.

Returns
The extension of the file

Definition at line 325 of file Path.cpp.

◆ filename()

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

Return the filename.

Returns
The filename

Definition at line 321 of file Path.cpp.

◆ folder()

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

Return the folder of the file.

Returns
The folder of the file

Definition at line 317 of file Path.cpp.

◆ isFileExist() [1/3]

bool utils::Path::isFileExist ( ) const

Test if file exist on the computer.

Returns
If file exist on the computer

Definition at line 73 of file Path.cpp.

◆ isFileExist() [2/3]

bool utils::Path::isFileExist ( const 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 74 of file Path.cpp.

◆ isFileExist() [3/3]

bool utils::Path::isFileExist ( const 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 77 of file Path.cpp.

◆ isFileReadable()

bool utils::Path::isFileReadable ( ) const

Test if file exist on the computer and is accessible.

Returns
If file is readable

Definition at line 92 of file Path.cpp.

◆ isFolderExist() [1/3]

bool utils::Path::isFolderExist ( ) const

Test if folder exists on the computer.

Returns
If folder exists

Definition at line 105 of file Path.cpp.

◆ isFolderExist() [2/3]

bool utils::Path::isFolderExist ( const 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 107 of file Path.cpp.

◆ isFolderExist() [3/3]

bool utils::Path::isFolderExist ( const 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 111 of file Path.cpp.

◆ originalPath()

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

Return original path as it was at constructor time.

Returns
The original path

Definition at line 308 of file Path.cpp.

◆ parseFileName()

void utils::Path::parseFileName ( const String & path,
utils::String & folder,
utils::String & filename,
utils::String & extension )
static

Parse a path in folder, filename and extension.

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

Definition at line 134 of file Path.cpp.

◆ relativePath() [1/3]

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

Return relative path to current working directory.

Returns
The relative path to curent working directory

Definition at line 169 of file Path.cpp.

◆ relativePath() [2/3]

utils::String utils::Path::relativePath ( const Path & path,
const 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 177 of file Path.cpp.

◆ relativePath() [3/3]

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

Return relative path to the specified folder.

Parameters
relativeToRelative to that path
Returns
The relative path

Definition at line 173 of file Path.cpp.

◆ setExtension()

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

Set the extension.

Parameters
extThe extension

Definition at line 323 of file Path.cpp.

◆ setFilename()

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

Set the filename.

Parameters
nameThe filename

Definition at line 319 of file Path.cpp.

◆ setFolder()

void utils::Path::setFolder ( const String & folder)

Set the folder of the file.

Parameters
folderThe folder of the file

Definition at line 312 of file Path.cpp.

◆ setIsFolderAbsolute()

void utils::Path::setIsFolderAbsolute ( )
protected

Set if folder is absolute.

Definition at line 327 of file Path.cpp.

◆ toUnixFormat()

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

Return the path to Unix format.

Parameters
pathThe path to convert
Returns
The path in Unix format

Definition at line 277 of file Path.cpp.

◆ toWindowsFormat()

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

Return the path to Windows format.

Parameters
pathThe path to convert
Returns
The path in Windows format

Definition at line 298 of file Path.cpp.

Member Data Documentation

◆ m_extension

std::shared_ptr<String> BIORBD_NAMESPACE::utils::Path::m_extension
protected

The extension.

Definition at line 240 of file Path.h.

◆ m_filename

std::shared_ptr<String> BIORBD_NAMESPACE::utils::Path::m_filename
protected

The filename.

Definition at line 239 of file Path.h.

◆ m_folder

std::shared_ptr<String> BIORBD_NAMESPACE::utils::Path::m_folder
protected

The folder.

Definition at line 237 of file Path.h.

◆ m_isFolderAbsolute

std::shared_ptr<bool> BIORBD_NAMESPACE::utils::Path::m_isFolderAbsolute
protected

If folder is absolute.

Definition at line 238 of file Path.h.

◆ m_originalPath

std::shared_ptr<String> BIORBD_NAMESPACE::utils::Path::m_originalPath
protected

The original path at construction time.

Definition at line 236 of file Path.h.


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