Storage module
This document details the storage and appFile modules used within the Paxos project for file system interaction. The modules provide a platform-agnostic interface for file and directory manipulation, reading, and writing.
1. storage Module
This module provides the core file system functionalities.
1.1 storage::Path Class
Represents a file or directory path.
1.1.1 Constructors
Path(): Creates an empty path.Path(const std::string& raw): Creates a path from a string, parsing and simplifying it.Path(const Path& other): Copy constructor.
1.1.2 Methods
join(const Path& other): Appends another path to this path.join(const std::string& other): Appends a string representation of a path to this path.operator/(const Path& other) const: Returns a new path by joining this path with another.operator/(const std::string& other) const: Returns a new path by joining this path with a string representation of a path.operator/=(const Path& other): Appends another path to this path (in-place).operator/=(const std::string& other): Appends a string representation of a path to this path (in-place).operator=(const Path& other): Assignment operator.operator=(const std::string& other): Assigns a string representation of a path to this path.operator==(const Path& other) const: Equality operator.assign(const Path& other): Assigns another path to this path.assign(const std::string& other): Assigns a string representation of a path to this path.clear(): Clears the path.str() const: Returns the string representation of the path.listdir(bool onlyDirs = false) const: Returns a vector of filenames within the directory represented by this path. IfonlyDirsis true, only directory names are returned.exists() const: Checks if the path exists.isfile() const: Checks if the path represents a file.isdir() const: Checks if the path represents a directory.newfile() const: Creates a new empty file at the specified path.newdir() const: Creates a new directory at the specified path.remove() const: Removes the file or directory at the specified path.rename(const Path& to): Renames the file or directory at the specified path.
1.2 storage::FileStream Class
Provides an interface for reading and writing files.
1.2.1 Constructors
FileStream(): Creates an empty filestream.FileStream(const std::string& path, Mode mode): Creates a filestream and opens the specified file with the given mode.