Vault
4.1
|
Classes | |
class | VAbstractFileStream |
VAbstractFileStream is a VStream subclass that implements the common part of the buffered and unbuffered file concrete subclasses, and defines the pure virtual API that they must implement. More... | |
class | VBufferedFileStream |
VBufferedFileStream is a concrete VStream class that implements stream i/o on a file, using buffered i/o APIs (e.g., fopen/fclose/fread/fwrite). More... | |
class | VDirectIOFileStream |
VDirectIOFileStream is a concrete VStream class that implements stream i/o on a file, using unbuffered i/o APIs (e.g., open/close/read/write). More... | |
class | VFSNodeInfo |
VFSNodeInfo holds file system information about a node, and is used internally by VFSNode and its platform-specific helper functions. More... |
The Vault uses the term "node" to mean either a file or directory within the file system. The class VFSNode is what you use to specify or identify a particular node in the file system. Operations that are carried out on nodes without requiring i/o on file contents, are defined as methods of VFSNode; you invoke methods on the VFSNode object whose path represents the file or directory you want to act on.
A VFSNode can represent a file or directory that does not currently exist. Naturally, that's how you would create a new directory: you would create a VFSNode to point to the path of the directory you want to create, and then you would call its mkdir() method. The mkdirs() method will ensure that any non-existent intermediate directories are created along the way, if you are creating a deep directory whose ancestory directory hierarchy does not yet exist. You can remove a directory or file by calling its rm() method.
Similarly, to create a new file, you'd make a VFSNode for the location where you want to create it, and then you'd use a VBufferedFileStream to create the file and write to it.
You can test the existence of a file or directory by calling exists(). If you need to know the difference between a file and a directory, you can call isDirectory() and isFile(), both of which return false if the node is of the other type or simply does not exist at all.
You can also use VFSNode to traverse the directory hierarchy, walking down to subdirectories and files by calling getChildNode() or getChildPath(), and walking up to a parent directory by calling getParentNode() or getParentPath(). In each case you are invoking the method on a VFSNode that represents the node whose child or parent you wish to locate.
You can get a directory node's list of files and subdirectories by calling list().
To perform i/o on a file, you will typically pass the VFSNode object that represents the file to a VBufferedFileStream object's constructor or setNode() method. Then you can call that object's methods to open the file stream in read-only, read-write, or write/create mode. From there you'll typically use a VBinaryIOStream or VTextIOStream object to actually format the file data correct (or to read it correctly).