#include <fs.h>
Public Types | |
enum | ListMode { kListFilesOnly = 1, kListDirectoriesOnly = 2, kListAll = 3 } |
Public Member Functions | |
FSNode () | |
FSNode (const Path &path) | |
bool | operator< (const FSNode &node) const |
bool | exists () const |
FSNode | getChild (const String &name) const |
bool | getChildren (FSList &fslist, ListMode mode=kListDirectoriesOnly, bool hidden=true) const |
U32String | getDisplayName () const override |
String | getName () const override |
String | getFileName () const override |
Path | getPathInArchive () const override |
virtual String | getRealName () const |
Path | getPath () const |
FSNode | getParent () const |
bool | isDirectory () const override |
void | listChildren (Common::ArchiveMemberList &childList, const char *pattern=nullptr) const override |
bool | isReadable () const |
bool | isWritable () const |
SeekableReadStream * | createReadStream () const override |
SeekableReadStream * | createReadStreamForAltStream (AltStreamType altStreamType) const override |
SeekableWriteStream * | createWriteStream (bool atomic=true) const |
bool | createDirectory () const |
Public Member Functions inherited from Common::ArchiveMember | |
virtual bool | isInMacArchive () const |
FSNode, short for "File System Node", provides an abstraction for file paths, allowing for portable file system browsing. This means, for example, that multiple or single roots have to be supported (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
To this end, we abstract away from paths; implementations can be based on paths (and it is left to them whether '/', '\', or ':' is the path separator) but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
Flag to tell listDir() which kind of files to list.
Common::FSNode::FSNode | ( | ) |
Create a new pathless FSNode. Since there is no path associated with this node, path-related operations (i.e. exists(), isDirectory(), getPath()) will always return false or raise an assertion.
|
explicit |
Create a new FSNode referring to the specified path. This is the counterpart to the path() method.
If the path is empty or equals ".", then a node representing the "current directory" will be created. If that is not possible (since e.g. the operating system does not support the concept), some other directory is used (usually the root directory).
bool Common::FSNode::operator< | ( | const FSNode & | node | ) | const |
Compare the name of this node to the name of another. Directories go before normal files.
bool Common::FSNode::exists | ( | ) | const |
Indicate whether the object referred by this node exists in the file system or not.
Create a new node referring to a child node of the current node, which must be a directory node (otherwise an invalid node is returned). If a child matching the name exists, a normal node for it is returned. If no child with the name exists, a node for it is still returned, but exists() will return 'false' for it. This node can however be used to create a new file using the createWriteStream() method.
name | Name of a child of this directory. |
bool Common::FSNode::getChildren | ( | FSList & | fslist, |
ListMode | mode = kListDirectoriesOnly , |
||
bool | hidden = true |
||
) | const |
Return a list of all child nodes of this directory node. If called on a node that does not represent a directory, false is returned.
|
overridevirtual |
Return a human-readable string for this node, usable for display (e.g. in the GUI code). Do not rely on it being usable for anything else, like constructing paths.
Reimplemented from Common::ArchiveMember.
|
overridevirtual |
Return a string representation of the name of the file. This can be used e.g. by detection code that relies on matching the name of a given file. However, it is not suitable for use with fopen / File::open, nor should it be archived.
Implements Common::ArchiveMember.
|
overridevirtual |
Return a string representation of the name of the file.
Implements Common::ArchiveMember.
|
overridevirtual |
Return a string representation of the name of the file. Since FSNode parents are always the parent FSDirectory, this will not return a full path, only the file name.
Implements Common::ArchiveMember.
|
virtual |
Return a string representation of the name of the file, without any Punycode transformation. This can be used e.g. by detection code that relies on matching the name of a given file. However, it is not suitable for use with fopen / File::open, nor should it be archived.
Path Common::FSNode::getPath | ( | ) | const |
Return a path representation of the file that is suitable for archiving (i.e. writing to the config file). What a 'path' is differs greatly from system to system.
FSNode Common::FSNode::getParent | ( | ) | const |
Get the parent node of this node. If this node has no parent node, then it returns a duplicate of this node.
|
overridevirtual |
Indicate whether the node refers to a directory or not.
Reimplemented from Common::ArchiveMember.
|
overridevirtual |
Adds the immediate children of this FSNode to a list, optionally matching a pattern. Has no effect if this FSNode is not a directory.
Reimplemented from Common::ArchiveMember.
bool Common::FSNode::isReadable | ( | ) | const |
Indicate whether the object referred by this node can be read from or not.
If the node refers to a directory, readability implies being able to read and list the directory entries.
If the node refers to a file, readability implies being able to read the contents of the file.
bool Common::FSNode::isWritable | ( | ) | const |
Indicate whether the object referred by this node can be written to or not.
If the node refers to a directory, writability implies being able to modify the directory entry (i.e. rename the directory, remove it, or write files inside of it).
If the node refers to a file, writability implies being able to write data to the file.
|
overridevirtual |
Create a SeekableReadStream instance corresponding to the file referred by this node. This assumes that the node actually refers to a readable file. If this is not the case, 0 is returned.
Implements Common::ArchiveMember.
|
overridevirtual |
Create a SeekableReadStream instance corresponding to an alternate stream of the file referred by this node. This assumes that the node actually refers to a readable file and the alternate stream exists. If either is not the case, nullptr is returned.
Implements Common::ArchiveMember.
SeekableWriteStream* Common::FSNode::createWriteStream | ( | bool | atomic = true | ) | const |
Create a WriteStream instance corresponding to the file referred by this node. This assumes that the node actually refers to a readable file. If this is not the case, 0 is returned.
When an atomic write stream is requested, the backend will write the data in a temporary file before moving it to its final destination.
atomic | Request for an atomic file write when closing. |
bool Common::FSNode::createDirectory | ( | ) | const |
Create a directory referred by this node. This assumes that this node refers to a non-existing directory. If this is not the case, false is returned.