CUTB
Public Member Functions | List of all members
cutb::utils::FilePath Class Reference

An object of this class analyzes a path string and gives information about its parent path, stem, and extension. More...

Public Member Functions

 FilePath (const char *const path)
 Constructs a new file path object from the parameter. More...
 
size_t parent_size () const
 Returns the parent path size. More...
 
size_t stem_size () const
 Returns the stem size. More...
 
size_t extension_size () const
 Returns the extension size. More...
 
size_t filename_size () const
 Returns the filename size, which is stem size plus extension size. More...
 
const char * parent_ptr () const
 Returns a pointer to a string of the parent path. More...
 
const char * stem_ptr () const
 Returns a pointer to a string of the stem. More...
 
const char * extension_ptr () const
 Returns a pointer to a string of the extension. More...
 
const char * filename_ptr () const
 Returns a pointer to a string of the filename, which is stem plus extension. More...
 

Detailed Description

An object of this class analyzes a path string and gives information about its parent path, stem, and extension.

This class does a rough analysis, using the last slash and the last dot in the path string.

In this class,

For example, "../foo/bar.baz" is split into the parent path of "../foo/", the stem of "bar", and the extension of ".baz".

This analysis does not work correctly for special paths such as dot (".") or dot-dot ("..").

Note
std::filesystem::path should be used instead of this class if it is possible.

Constructor & Destructor Documentation

cutb::utils::FilePath::FilePath ( const char *const  path)
inline

Constructs a new file path object from the parameter.

Parameters
patha null-terminated string of a file path

Member Function Documentation

const char* cutb::utils::FilePath::extension_ptr ( ) const
inline

Returns a pointer to a string of the extension.

If there is no extension, NULL is returned.

Returns
a pointer to the extension or NULL.
size_t cutb::utils::FilePath::extension_size ( ) const
inline

Returns the extension size.

If there is no extension, zero is returned.

Returns
the extension size or zero.
const char* cutb::utils::FilePath::filename_ptr ( ) const
inline

Returns a pointer to a string of the filename, which is stem plus extension.

If there is neither stem nor extension, NULL is returned.

Returns
a pointer to the filename or NULL.
size_t cutb::utils::FilePath::filename_size ( ) const
inline

Returns the filename size, which is stem size plus extension size.

If there is neither stem nor extension, zero is returned.

Returns
the filename size or zero.
const char* cutb::utils::FilePath::parent_ptr ( ) const
inline

Returns a pointer to a string of the parent path.

If there is no parent path, NULL is returned.

Returns
a pointer to the parent path or NULL.
size_t cutb::utils::FilePath::parent_size ( ) const
inline

Returns the parent path size.

If there is no parent path, zero is returned.

Returns
the parent path size or zero.
const char* cutb::utils::FilePath::stem_ptr ( ) const
inline

Returns a pointer to a string of the stem.

If there is no stem, NULL is returned.

Returns
a pointer to the stem or NULL.
size_t cutb::utils::FilePath::stem_size ( ) const
inline

Returns the stem size.

If there is no stem, zero is returned.

Returns
the stem size or zero.

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