FileHelperRK
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
FileHelperRK::ParsedPath Class Reference

Container for a parsed pathname (Unix-style, with slashes) More...

#include <FileHelperRK.h>

Public Member Functions

int parse (const char *path)
 Parse a pathname (Unix-style, with slashes)
 
void clear ()
 Clear the parsed data in this object.
 
bool getStartsWithSlash () const
 Returns true if path starts with a slash (is absolute)
 
bool getEndsWithSlash () const
 Returns true if the path ends with a slash.
 
int getNumParts () const
 Get the number of path parts.
 
String getPart (size_t index) const
 Get a pathname part from its index.
 
String operator[] (size_t index) const
 Get a pathname part from its index.
 
String generatePathString (int numParts=-1)
 Generate a new pathname string.
 
String getFileBaseName () const
 Get the filename of the last component of the path without an extension.
 
String getFileExtension () const
 Get the filename extension of the last component of the path.
 

Protected Attributes

bool startsWithSlash = false
 true if the parsed path began with a slash (absolute path)
 
bool endsWithSlash = false
 true if the parsed path ended with a slash
 
String fileBaseName
 Filename (last part of path) without extension.
 
String fileExtension
 Filename (last part of path) extension (does not contain dot)
 
std::vector< String > parts
 parsed parts of the pathname. Does not contain empty parts.
 

Detailed Description

Container for a parsed pathname (Unix-style, with slashes)

Member Function Documentation

◆ generatePathString()

String FileHelperRK::ParsedPath::generatePathString ( int numParts = -1)

Generate a new pathname string.

Parameters
numParts-1 to include the whole string
Returns
String

◆ getEndsWithSlash()

bool FileHelperRK::ParsedPath::getEndsWithSlash ( ) const
inline

Returns true if the path ends with a slash.

Returns
true Path ends with a slash

Normally a path ending with a slash signifies a directory, but this function does not validate that this is true on the file system. It merely tests the input string.

◆ getFileBaseName()

String FileHelperRK::ParsedPath::getFileBaseName ( ) const
inline

Get the filename of the last component of the path without an extension.

Returns
String

◆ getFileExtension()

String FileHelperRK::ParsedPath::getFileExtension ( ) const
inline

Get the filename extension of the last component of the path.

Returns
String

◆ getNumParts()

int FileHelperRK::ParsedPath::getNumParts ( ) const
inline

Get the number of path parts.

Returns
int (0 = empty path, 1 = one part)

◆ getPart()

String FileHelperRK::ParsedPath::getPart ( size_t index) const
inline

Get a pathname part from its index.

Parameters
index0-based index to retrieve, must be 0 <= index < getNumParts()
Returns
String Copy of the pathname part

◆ getStartsWithSlash()

bool FileHelperRK::ParsedPath::getStartsWithSlash ( ) const
inline

Returns true if path starts with a slash (is absolute)

Returns
true Absolute path
false Relative path

◆ operator[]()

String FileHelperRK::ParsedPath::operator[] ( size_t index) const
inline

Get a pathname part from its index.

Parameters
index0-based index to retrieve, must be 0 <= index < getNumParts()
Returns
String Copy of the pathname part

◆ parse()

int FileHelperRK::ParsedPath::parse ( const char * path)

Parse a pathname (Unix-style, with slashes)

Parameters
pathc-string containing an absolute or relative Unix-style pathname (slash separated)
Returns
int SYSTEM_ERROR_NONE (0) on success or a system error code (non-zero)

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