path


A path is a sequence of steps through a file system that leads to a file system entry. The following are types of paths.

Microsoft Windows platforms have additional categories of absolute paths.

Library

File<ToolKit>

Declaration

#include <ospace/file/path.h>

class os_path

Interface

Constructor
os_path()
Constructs an empty path.
Constructor
os_path( const string& filepath )
Constructs a path representing filepath .
Constructor
os_path( const string& dirpath , const string& filename )
Constructs a path to the file specified by dirpath and filename .
Constructor
os_path( const string& dirpath , const string& base , const string& extension )
Constructs a path to the file specified by dirpath , base, and extension .
Constructor
os_path( char drive , const string& dirpath , const string& filename )
Constructs a path to the file specified by drive , dirpath , and filename .
Constructor
os_path( char drive , const string& dirpath , const string& base , const string& extension )
Constructs a path to the file specified by drive , dirpath , base , and extension .
Constructor
os_path( const string& server , const string& sharepoint , const string& dirpath , const string& filename )
Constructs a path to the file specified by server , sharepoint , dirpath , and filename .
Constructor
os_path( const string& server , const string& sharepoint , const string& dirpath , const string& base , const string& extension )
Constructs a path to the file specified by server , sharepoint , drive , dirpath , base , and extension .
Constructor
os_path( const os_path& path )
Constructs a path with the same value as path .
[]
string operator[]( int level )
Returns a string containing the directory level of this path.
=
os_path& operator=( const os_path& path )
Assigns this object's value to path .
=
os_path& operator=( const string& path )
Assigns this object's value to path .
<
bool operator<( const os_path& path )
Returns true if this path's value is less than path .
<
bool operator<( const string& path )
Returns true if this path's value is less than path .
!=
bool operator!=( const os_path& path )
Returns true if this path's value is different than path .
!=
bool operator!=( const string& path )
Returns true if this path's value is different than path .
==
bool operator==( const os_path& path )
Returns true if this path's value is equal to path .
==
bool operator==( const string& path )
Returns true if this path's value is equal to path .
(const char*)
operator const char*() const
Returns a constant pointer to this path's value.
(const string&)
operator const string&() const
Returns a constant reference to this path's value.
absolute
bool absolute() const
Returns true if this path has an absolute value, rather than a relative value.
append
os_path& append( const string& string )
Appends string to this path and returns a reference to the path.
append
os_path& append( const os_path& filepath )
Appends filepath to this path and returns a reference to the path.
base
string base() const
Returns the base section of the filename or returns an empty string if this path does not contain a filename component.
base
os_path& base( const string& string ) const
Sets the base() component to string .
become_relative_to
void become_relative_to( const string& dir )
Modifies this path to represent the current value relative to dir .
become_simplified
void become_simplified()
Modifies this path to become simplified.
cd
os_path& cd( const string& dir )
Similar to the cd shell command, this method updates the dirpath component of the path, using the supplied relative or absolute dir . The filename component of the path remains unchanged.
cd
os_path cd( const string& dir ) const
Returns a new path object with the same filename as this path but with the dirpath component updated by the absolute or relative address specified by dir .
default_path_separator
/* static */ char default_path_separator()
Returns the default path separator value for this platform.
directory
string directory() const
Returns the directory component.
directory
os_path& directory( const string& string )
Sets the directory component to string .
directory_path
bool directory_path() const
Returns true if this path has only a directory path component.
drive
string drive() const
Returns the drive specifier or returns an empty string if this path does not contain a dirpath component.
drive
os_drive& drive( char drive )
Sets the drive specifier to drive .
drive_separator
char drive_separator() const
Returns the character used to separate drive components.
drive_separator
os_path& drive_separator( char separator )
Sets the drive separator character to separator .
extension
string extension() const
Returns the extension section of the filename or returns an empty string if this path does not contain a filename component.
extension
os_path& extension( const string& string )
Sets the extension() component to string .
extension_separator
char extension_separator() const
Returns the character used to separate the extension from the filename component.
extension_separator
os_path& extension_separator( char separator )
Sets the extension separator character to separator .
file_escape
char file_escape() const
Returns the character used to differentiate a path separate from the filename component.
file_escape
os_path& file_escape( char escape )
Sets the file escape character to escape .
filename
string filename() const
Returns the filename component.
filename
os_path& filename( const string& string )
Sets the filename component to string .
file_path
bool file_path() const
Returns true if this path has a filename component.
has_directory
bool has_directory() const
Returns true if this path has a directory path component.
has_drive
bool has_drive() const
Returns true if this path has a drive specifier.
has_extension
bool has_extension() const
Returns true if this path has a filename component with an extension.
has_unc
bool has_unc() const
Returns true if this path has a Universal Naming Convention (UNC) identifier.
head
string head() const
Returns the first section in the directory path or returns an empty string if this path does not contain a directory component.
head
os_path& head( const string& string )
Sets the head() component to string .
legal
bool legal( int level ) const
Returns true if level is a legal directory level.
levels
int levels() const
Returns the number of levels in this path's directory component.
no_drive
os_path& no_drive()
Removes the drive specifier from this path.
no_extension
os_path& no_extension()
Removes the filename extension from this path.
no_unc
os_path& no_unc()
Removes the UNC from this path.
path_separator
char path_separator() const
Returns the character used to separate path components.
path_separator
os_path& path_separator( char separator )
Sets the path separator character to separator .
print
void print( ostream& stream ) const
Prints the path value to stream .
relative
bool relative() const
Returns true if this path has a relative value rather than an absolute value.
relative_to
os_path relative_to( const string& dir ) const
Returns a new path that represents the value of this path relative to dir .
section
os_path& section( int index , const string& string )
Replaces the section at index with string .
server
string server() const
Returns the server identifier.
server
os_path& server( const string& string )
Sets the server identifier to string .
share
string share() const
Returns the share point identifier.
share
os_path& share( const string& string )
Sets the share point identifier to string .
simplified
os_path simplified() const
Returns a simplified path.
tail
string tail() const
Returns the last section in the directory path or returns an empty string if this path does not contain a directory component.
tail
os_path& tail( const string& string )
Sets the tail() component to string .
unc
string unc() const
Returns the UNC identifier or returns an empty string if this path does not contain a UNC.
unc
os_path& unc( const string& string )
Sets the UNC identifier to string .

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_path& path )
Prints path to stream .

Universal Streaming Service

#include <ospace/uss/file.h>

<<
os_bstream& operator<<( os_bstream& stream , const os_path& path )
Writes path to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_path& path )
Reads path from stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.