Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/sys/Path.h>
Classes | |
class | DirIter |
class | DirReader |
class | PathIter |
class | PathSplit |
Static Public Member Functions | |
static bool | isSeparator (char c) |
static void | setCurrent (Path &path) |
static Path | current (void) |
static Path | home (void) |
static Path | temp (void) |
static PathSplit | splitPaths (string paths) |
Static Public Attributes | |
static const char | SEPARATOR = '/' |
static const char | PATH_SEPARATOR = ':' |
static const string | BACK_PATH = ".." |
This class represents a file path in the current file system.
It provides facilities to:
Referenced by Path::absolute(), Path::append(), Path::current(), Path::dirPart(), Path::home(), Path::parent(), Path::relativeTo(), and Path::temp().
|
inline |
Get the absolute path matching the current path.
References Path::current(), Path::home(), Path::isAbsolute(), Path::isHomeRelative(), Path::Path(), and String::substring().
Referenced by Path::canonical().
Build a new path by appending two paths.
path | Path to append. |
References Path::Path(), Path::SEPARATOR, and StringBuffer::toString().
Referenced by FileOutput::FileOutput().
io::OutStream * append | ( | void | ) |
Open or create a file with this path and write by appending to the content.
SystemException | Thrown if there is an IO error during operation. |
References System::appendFile().
Referenced by Path::operator/().
|
inline |
References CString::chars(), and String::toCString().
Referenced by System::appendFile(), System::createFile(), System::createRandomFile(), Path::DirIter::DirIter(), Path::exists(), FileItem::get(), FileItem::isDeletable(), Path::isDir(), Path::isExecutable(), Path::isFile(), FileItem::isReadable(), Path::isReadable(), FileItem::isWritable(), Path::isWritable(), Directory::make(), System::openRandomFile(), System::readFile(), and Path::setCurrent().
Get the base part of the path, that is, the path without the extension of the file part.
References String::lastIndexOf(), and String::substring().
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 Path::absolute(), Path::isRelative(), and Path::SEPARATOR.
Referenced by FileItem::get(), and System::getUnitPath().
References Path::subPathOf().
Get the current path.
References Path::Path().
Referenced by Path::absolute(), and Path::temp().
Return the directory part of the path.
References Path::Path(), and String::substring().
Referenced by elm::sys::evaluate().
Test if two paths are lexically equals.
Referenced by Path::operator!=(), and Path::operator==().
Test if the path matches a file, a directory or any file system object.
References Path::asSysString().
Referenced by Plugger::plugFile().
Get the extension of the referenced file name.
References String::lastIndexOf(), and String::substring().
Referenced by Plugger::plugFile().
Get the path of the home directory.
References Path::Path().
Referenced by Path::absolute(), and Path::temp().
Test if the path is absolute.
References String::length(), and Path::SEPARATOR.
Referenced by Path::absolute(), and Path::isRelative().
Test if the path matches a directory.
References Path::asSysString().
Referenced by Path::temp().
Test if the path is empty.
References String::isEmpty().
Test if the path matches an executable file system object.
References Path::asSysString().
Test if the path matches a file.
References Path::asSysString().
Referenced by Plugger::plugFile().
Test if the path is home-relative. On Unix, it is usually starting with "~".
References String::length().
Referenced by Path::absolute().
Test if the current path is prefix of the given one.
path | Path to test. |
References String::length(), Path::SEPARATOR, and String::startsWith().
Referenced by Path::prefixedBy().
Test if the path matches a readable file system object.
References Path::asSysString().
Referenced by Plugger::plugFile().
Test if the path is relative.
References Path::isAbsolute().
Referenced by Path::canonical().
|
inlinestatic |
References Path::SEPARATOR.
Test if the path matches a writable file system object.
References Path::asSysString().
Referenced by Path::temp().
Build the directory corresponding to this path.
SystemException | Thrown if there is an IO error during operation. |
References System::makeDir().
Create the directory given by this path and missing parent directories. Does nothing if the directory already exists.
SystemException | If there is an OS error or if a file with same name exist. |
References System::makeDirs().
Return the name part of the path.
References String::substring().
Referenced by Plugger::Iter::item(), FileItem::name(), and TestCase::test().
Test if the path is null.
References Path::toString().
Same as !equals().
References Path::equals().
Same as append.
References Path::append().
|
inline |
References elm::str().
References elm::str().
References elm::str().
Same as equals().
References Path::equals().
Find the parent path of the current or an empty path if there is no parent.
References Path::Path(), and String::substring().
Referenced by FileItem::isDeletable().
Test if the current path if prefixed by the given one.
path | Prefix path. |
References Path::isPrefixOf().
io::InStream * read | ( | void | ) |
Open for reading the file corresponding to this path.
SystemException | Thrown if there is an IO error during operation. |
References System::readFile().
Allow to read the content of a directory.
SystemException | If the path is not a directory or can not be accessed. |
Build a path which is the current path relative to the given base path.
base | Base path to be relative to. |
References Path::BACK_PATH, elm::io::base(), Path::Path(), String::substring(), and Path::toString().
Remove the file or the directory corresponding to this path. If this is a non-empty directory, remove its content recursively. No error is issued if the path does not exist.
SystemException | Thrown if there is an IO error during operation. |
References System::remove().
Change the extension if there is some one or add the given extension.
ext | New extension to put in. |
References Path::setExtension().
Change the extension if there is some one or add the given extension.
new_extension | New extension to put in. |
References String::lastIndexOf(), and StringBuffer::toString().
Referenced by Plugger::plugFile(), and Path::setExt().
Test if the current path is a sub-path of given path. This means that the path is a prefix of the current path.
References String::startsWith().
Referenced by Path::contains().
Get a temporary directory. If the OS does not provide any temporary directory, the current directory is selected. As a fallback, a "tmp" directory is created in the user home. If it can't be, the user home is returned.
References Path::current(), Path::home(), Path::isDir(), Path::isWritable(), System::makeDir(), and Path::Path().
Convert the path to string.
Referenced by HashKey< sys::Path >::hash(), elm::sys::isLibrary(), Path::operator const String &(), elm::sys::operator<<(), Path::relativeTo(), and XOMUnserializer::XOMUnserializer().
Return the path with the last component extension removed.
References String::lastIndexOf(), and String::substring().
io::OutStream * write | ( | void | ) |
Create a file with this path or overwrite an existing one.
SystemException | Thrown if there is an IO error during operation. |
References System::createFile().
Referenced by FileOutput::FileOutput().
|
static |
Symbol used to represent a backward move in the path.
Referenced by Path::relativeTo().
|
static |
Separator character for a list of paths.
Referenced by Plugger::Plugger().
|
static |
Separator character for the components of a path.
Referenced by Path::append(), Path::canonical(), Path::isAbsolute(), Path::isPrefixOf(), and Path::isSeparator().