23 #include "lfilesystem/lfilesystem_Export.h"
89 Directory& operator= (
const std::string_view& newPath);
111 [[nodiscard]]
bool contains (
const std::string_view& childName)
const;
121 [[nodiscard]]
bool isDirectory() const noexcept final;
122 [[nodiscard]]
bool isFile() const noexcept final;
123 [[nodiscard]]
bool isSymLink() const noexcept final;
132 bool createIfDoesntExist() const noexcept final;
145 [[nodiscard]]
Path getRelativePath (const
Path& inputPath) const;
153 [[nodiscard]]
File getChildFile (const std::string_view& filename,
bool createIfNeeded = false) const;
158 [[nodiscard]] std::vector<
File> getChildFiles (
bool recurse = true,
bool includeHiddenFiles = true) const;
164 void iterateFiles (
FileCallback&& callback,
bool recurse = true,
bool includeHiddenFiles = true) const;
172 [[nodiscard]]
bool containsSubdirectories() const;
177 [[nodiscard]]
Directory getChildDirectory (const std::string_view& subdirectoryName,
bool createIfNeeded = false) const;
182 [[nodiscard]] std::vector<
Directory> getChildDirectories (
bool recurse = true,
bool includeHiddenFiles = true) const;
188 void iterateDirectories (
DirectoryCallback&& callback,
bool recurse = true,
bool includeHiddenFiles = true) const;
202 [[nodiscard]]
SymLink createChildSymLink (const std::string_view& symLinkName,
208 [[nodiscard]] std::vector<
SymLink> getChildSymLinks (
bool recurse = true,
bool includeHiddenFiles = true) const;
214 void iterateSymLinks (
SymLinkCallback&& callback,
bool recurse = true,
bool includeHiddenFiles = true) const;
224 [[nodiscard]]
FilesystemEntry getChild (const std::string_view& childName,
bool createIfNeeded = false) const;
229 [[nodiscard]] std::vector<
FilesystemEntry> getAllChildren (
bool recurse = true,
bool includeHiddenFiles = true) const;
240 bool includeHiddenFiles = true) const;
248 bool includeHiddenFiles = true) const;
261 using iterator_category = std::forward_iterator_tag;
263 using difference_type = std::ptrdiff_t;
268 [[nodiscard]]
Iterator operator++ (
int);
284 using VectorType = std::vector<FilesystemEntry>;
288 std::shared_ptr<VectorType> entries {
nullptr };
290 VectorType::size_type idx { 0UL };
This class represents a directory on the filesystem.
bool contains(const std::string_view &childName) const
Returns true if this directory contains a child with the specified name.
std::function< void(const FilesystemEntry &)> FilesystemEntryCallback
A callback for FilesystemEntry objects.
std::function< void(const SymLink &)> SymLinkCallback
A callback for SymLink objects.
bool setAsWorkingDirectory() const
Sets this directory as the current working directory.
std::uintmax_t sizeInBytes() const final
Returns the size of this directory, calculated as the cumulative size of all of this directory's cont...
bool isEmpty() const
Returns true if this directory contains no children.
bool contains(const FilesystemEntry &entry, std::size_t depthLimit=50) const
Returns true if this directory contains the passed FilesystemEntry.
std::function< void(const File &)> FileCallback
A callback for File objects.
bool isCurrentWorkingDirectory() const
Returns true if this directory is the system's current working directory.
Iterator begin() const
Returns an iterator to the first entry in this directory.
Iterator end() const
Returns an iterator to the last entry in this directory.
std::function< void(const Directory &)> DirectoryCallback
A callback for Directory objects.
This class represents a file on the filesystem.
The base class for any kind of object on the filesystem.
FilesystemEntry()=default
Creates a FilesystemEntry with an empty path.
This class represents a symbolic link on the filesystem.
std::filesystem::path Path
Convenience typedef for filesystem paths.
This file defines the File and TempFile classes.
This file defines the FilesystemEntry class.
This file defines the files::SymLink class.
An iterator class that allows iterating a directory like a standard C++ container.