This class holds a file.
More...
#include <File.h>
|
| | File () |
| | Creates an empty file.
|
| |
| | File (const std::string &filename) |
| | Create a new file.
|
| |
| bool | isValid () const override |
| | Returns whether the path is valid.
|
| |
| bool | exists () const override |
| | Returns whether the file exists already.
|
| |
| bool | remove () const |
| | Removes this file from the filesystem.
|
| |
| std::string | base () const |
| | Returns the base of this file.
|
| |
| std::string | extension () const |
| | Returns the extension of this file.
|
| |
| std::string | name () const |
| | Returns the name of this file.
|
| |
| std::string | baseName () const |
| | Returns the base name of this file.
|
| |
| virtual | ~Path ()=default |
| | Destructs a path.
|
| |
| Type | type () const |
| | Returns the type of this path.
|
| |
| bool | isAbsolute () const |
| | Returns whether this path is absolute.
|
| |
| bool | isRelative () const |
| | Returns whether this path is relative.
|
| |
| bool | isNull () const |
| | Returns whether this path holds no valid.
|
| |
| bool | operator== (const Path &right) const |
| | Returns whether two paths are equal.
|
| |
| bool | operator!= (const Path &path) const |
| | Returns whether two paths are not equal.
|
| |
| const std::string & | operator() () const |
| | Returns the value of this path.
|
| |
| bool | operator< (const Path &path) const |
| | Less operator comparing the actual strings of two paths.
|
| |
|
| static bool | existsApple (const std::string &file) |
| | Returns whether a file exists (specialization for Apple platforms).
|
| |
| static bool | isSeparator (const char character) |
| | Returns whether a given character is a separator.
|
| |
| static char | defaultSeparator () |
| | Returns the default separator of a path.
|
| |
|
| static std::string::size_type | extensionPosition (const std::string &path) |
| | Returns the position of the dot separating the extension from the remaining path.
|
| |
◆ File() [1/2]
| Ocean::IO::File::File |
( |
| ) |
|
◆ File() [2/2]
| Ocean::IO::File::File |
( |
const std::string & |
filename | ) |
|
|
explicit |
Create a new file.
- Parameters
-
◆ base()
| std::string Ocean::IO::File::base |
( |
| ) |
const |
Returns the base of this file.
The file's base is the entire file path without file extension (and the character in front of the extension).
In case the file does not have an extension, the base is the entire file path.
File: base():
"example.bmp" "example"
"example" "example"
"example.tar.gz" "example.tar"
"/first/second/image.png" "/first/second/image"
"first.second/example" "first.second/example"
- Returns
- File base
◆ baseName()
| std::string Ocean::IO::File::baseName |
( |
| ) |
const |
Returns the base name of this file.
The base name is the local filename without extension.
File: baseName():
"example.bmp" "example"
"example" "example"
"example.tar.gz" "example.tar"
"/first/second/image.png" "image"
"first.second/example" "example"
- Returns
- File base name
◆ exists()
| bool Ocean::IO::File::exists |
( |
| ) |
const |
|
overridevirtual |
◆ existsApple()
| static bool Ocean::IO::File::existsApple |
( |
const std::string & |
file | ) |
|
|
static |
Returns whether a file exists (specialization for Apple platforms).
- Parameters
-
- Returns
- True, if so
◆ extension()
| std::string Ocean::IO::File::extension |
( |
| ) |
const |
Returns the extension of this file.
A dot within a directory does not separate an extension.
File: extension():
"example.bmp" "bmp"
"example" ""
"example.tar.gz" "gz"
"/first/second/image.png" "png"
"first.second/example" ""
- Returns
- File extension, empty if the file does not have an extension
◆ extensionPosition()
| static std::string::size_type Ocean::IO::File::extensionPosition |
( |
const std::string & |
path | ) |
|
|
staticprotected |
Returns the position of the dot separating the extension from the remaining path.
A dot within a directory does not separate an extension, e.g. "first.second/example" does not have an extension.
- Parameters
-
| path | The path for which the position will be determined |
- Returns
- The position of the dot, 'npos' if the path does not have an extension
◆ isValid()
| bool Ocean::IO::File::isValid |
( |
| ) |
const |
|
overridevirtual |
◆ name()
| std::string Ocean::IO::File::name |
( |
| ) |
const |
Returns the name of this file.
The file's name is the local filename including the file extension without the prefix path.
File: name():
"example.bmp" "example.bmp"
"example" "example"
"example.tar.gz" "example.tar.gz"
"/first/second/image.png" "image.png"
"first.second/example" "example"
- Returns
- File name
◆ remove()
| bool Ocean::IO::File::remove |
( |
| ) |
const |
Removes this file from the filesystem.
- Returns
- True, if succeeded
- See also
- exists().
The documentation for this class was generated from the following file: