apfs::directory_entry¶
-
class directory_entry¶
Represents a filesystem entry.
A directory entry may represent a file, directory, symbolic link, or any other entry type described by directory_entry_type
Public Functions¶
-
std::vector<directory_entry> list_children() const¶
Lists the files in this entry iff it is a directory (
DIRENT_DIR).- Throws:¶
If– this entry does not represent a directory, an error is thrown.
-
directory_entry resolve(const std::string &path, bool follow_last = true) const¶
Navigates to a given path relative to this directory entry.
Follows all symbolic links encountered in the path.
-
void read_file(std::ostream &os, off_t offset = 0, apfs_ssize_t size = -1) const¶
Reads the file represented by this entry iff it is a file (
DIRENT_FILE).- Throws:¶
If– this entry does not represent a regular file, an error is thrown.
-
std::string read_symlink() const¶
Gets the path pointed to by this entry iff it is a symbolic link (
DIRENT_LINK).- Throws:¶
If– this entry does not represent a symbolic link, an error is thrown.
-
directory_entry follow_symlink(int level = -1) const¶
Resolves the symbolic link
leveltimes.By default,
levelis-1, which repeatedly resolves symbolic links until the resulting entry is no longer a symbolic link.- Throws:¶
If– the path points outside the filesystem (e.g./Volumes/VolName/fileinstead of/file).If–levelis-1and the symbolic links form a cycle.
Public Members¶
-
std::string name¶
The name of this directory entry. Note that this is not the full path.
-
directory_entry_type type¶
The type of this directory entry.
-
std::vector<directory_entry> list_children() const¶