Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::sys::Path Class Reference

#include <elm/sys/Path.h>

Classes

class  PathIter
 

Public Member Functions

 Path (void)
 
 Path (const char *path)
 
 Path (CString path)
 
 Path (const String &path)
 
 Path (const Path &path)
 
Path canonical (void) const
 
Path absolute (void) const
 
Path append (Path path) const
 
Path parent (void) const
 
Path setExtension (CString new_extension) const
 
const StringtoString (void) const
 
String namePart (void) const
 
sys::Path dirPart (void) const
 
Path basePart (void) const
 
String extension (void) const
 
bool isAbsolute (void) const
 
bool isRelative (void) const
 
bool isHomeRelative (void) const
 
bool equals (Path &path) const
 
bool contains (Path &path) const
 
bool exists (void) const
 
bool isFile (void) const
 
bool isDir (void) const
 
bool isReadable (void) const
 
bool isWritable (void) const
 
bool isExecutable (void) const
 
Pathoperator= (const char *str)
 
Pathoperator= (CString str)
 
Pathoperator= (const String &str)
 
Pathoperator= (const Path &path)
 
bool operator== (Path path) const
 
bool operator!= (Path path) const
 
Path operator/ (const Path &path) const
 
 operator const String & (void) const
 
 operator bool (void) const
 
const char * operator& (void) const
 

Static Public Member Functions

static bool isSeparator (char c)
 
static void setCurrent (Path &path)
 
static Path current (void)
 
static Path home (void)
 

Static Public Attributes

static const char SEPARATOR = '/'
 
static const char PATH_SEPARATOR = ':'
 

Detailed Description

This class represents a file path in the current file system.

Constructor & Destructor Documentation

elm::sys::Path::Path ( void  )
elm::sys::Path::Path ( const char *  path)
elm::sys::Path::Path ( CString  path)
elm::sys::Path::Path ( const String path)
elm::sys::Path::Path ( const Path path)

Member Function Documentation

Path elm::sys::Path::absolute ( void  ) const

Get the absolute path matching the current path.

Returns
Matching absolute path.

References current(), home(), isAbsolute(), isHomeRelative(), Path(), and elm::String::substring().

Referenced by canonical().

Path elm::sys::Path::append ( Path  path) const

Build a new path by appending two paths.

Parameters
pathPath to append.
Returns
New path.

References Path(), SEPARATOR, and elm::StringBuffer::toString().

Referenced by operator/().

Path elm::sys::Path::basePart ( void  ) const

Get the base part of the path, that is, the path without the extension of the file part.

Returns
Base part of the path.

References elm::String::lastIndexOf(), and elm::String::substring().

Path elm::sys::Path::canonical ( void  ) const

Get the canonical form of the current path. Usually, a relative path becomes an absolute one. Relative operators (.., .) are removed if it is possible.

References absolute(), isRelative(), and SEPARATOR.

Referenced by elm::sys::System::getUnitPath().

bool elm::sys::Path::contains ( Path path) const

Test if a path lexically contains another path.

Returns
True if it contains, false else.

References elm::String::startsWith().

Path elm::sys::Path::current ( void  )
static

Get the current path.

Returns
Current path.

References Path().

Referenced by absolute().

sys::Path elm::sys::Path::dirPart ( void  ) const

Return the directory part of the path.

Returns
Directory part.

References Path(), and elm::String::substring().

Referenced by elm::sys::evaluate().

bool elm::sys::Path::equals ( Path path) const

Test if two paths are lexically equals.

Returns
True if they equals, false else.

Referenced by operator!=(), and operator==().

bool elm::sys::Path::exists ( void  ) const

Test if the path matches a file, a directory or any file system object.

Returns
True if it exists (or is not accessible), false else.

References toString().

String elm::sys::Path::extension ( void  ) const

Get the extension of the referenced file name.

Returns
Extension (without ".") or an empty string if there is no extension.

References elm::String::lastIndexOf(), and elm::String::substring().

Path elm::sys::Path::home ( void  )
static

Get the path of the home directory.

Returns
Home directory.

References Path().

Referenced by absolute().

bool elm::sys::Path::isAbsolute ( void  ) const

Test if the path is absolute.

Returns
True if it is absolute, false else.

References elm::String::length(), and SEPARATOR.

Referenced by absolute(), and isRelative().

bool elm::sys::Path::isDir ( void  ) const

Test if the path matches a directory.

Returns
True if it is a directory (and is accessible), false else.

References toString().

bool elm::sys::Path::isExecutable ( void  ) const

Test if the path matches an executable file system object.

Returns
True if it executable (and accessible), false else.

References toString().

bool elm::sys::Path::isFile ( void  ) const

Test if the path matches a file.

Returns
True if it is a file (and is accessible), false else.

References toString().

bool elm::sys::Path::isHomeRelative ( void  ) const

Test if the path is home-relative. On Unix, it is usually starting with "~".

Returns
True if it is home-relative, false else.

References elm::String::length().

Referenced by absolute().

bool elm::sys::Path::isReadable ( void  ) const

Test if the path matches a readable file system object.

Returns
True if it readable (and accessible), false else.

References toString().

bool elm::sys::Path::isRelative ( void  ) const

Test if the path is relative.

Returns
True if it is relative, false else.

References isAbsolute().

Referenced by canonical().

static bool elm::sys::Path::isSeparator ( char  c)
static

References SEPARATOR.

bool elm::sys::Path::isWritable ( void  ) const

Test if the path matches a writable file system object.

Returns
True if it writable (and accessible), false else.

References toString().

String elm::sys::Path::namePart ( void  ) const

Return the name part of the path.

Returns
Name part.

References elm::String::substring().

Referenced by elm::sys::Plugger::Iterator::item(), and elm::sys::FileItem::name().

elm::sys::Path::operator bool ( void  ) const

Test if the path is null.

Returns
True if it is not null, false else.
elm::sys::Path::operator const String & ( void  ) const

References toString().

bool elm::sys::Path::operator!= ( Path  path) const

Same as !equals().

References equals().

const char* elm::sys::Path::operator& ( void  ) const
Path elm::sys::Path::operator/ ( const Path path) const

Same as append.

References append().

Path& elm::sys::Path::operator= ( const char *  str)
Path& elm::sys::Path::operator= ( CString  str)
Path& elm::sys::Path::operator= ( const String str)
Path& elm::sys::Path::operator= ( const Path path)
bool elm::sys::Path::operator== ( Path  path) const

Same as equals().

References equals().

Path elm::sys::Path::parent ( void  ) const

Find the parent path of the current or an empty path if there is no parent.

Returns
Parent path.

References Path(), and elm::String::substring().

Referenced by elm::sys::FileItem::isDeletable(), and elm::sys::Plugger::plugFile().

void elm::sys::Path::setCurrent ( Path path)
static

Change the current path.

Parameters
pathNew current path.
Path elm::sys::Path::setExtension ( CString  new_extension) const

Change the extension if there is some one or add the given extension.

Parameters
new_extensionNew extension to put in.
Returns
New path with extension set.

References elm::String::lastIndexOf(), and elm::StringBuffer::toString().

Referenced by elm::sys::Plugger::plugFile().

Member Data Documentation

const char elm::sys::Path::PATH_SEPARATOR = ':'
static
const char elm::sys::Path::SEPARATOR = '/'
static

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