Added some constructors and an empty() check to path references.

This commit is contained in:
Patrick 2023-12-29 23:32:14 +01:00
parent 1d14c1f3ff
commit 80310f3c5c

View File

@ -45,13 +45,20 @@ struct FileInfo
class PathReference
{
private:
class FileSystemAdapter* adapter_;
fs::path path_;
class FileSystemAdapter* adapter_ = nullptr;
fs::path path_ = {};
public:
PathReference() = default;
PathReference(const PathReference&) = default;
PathReference(PathReference&&) = default;
PathReference(class FileSystemAdapter* adapter, fs::path path) noexcept : adapter_(adapter), path_(std::move(path)) {}
PathReference& operator=(const PathReference&) = default;
PathReference& operator=(PathReference&&) = default;
auto operator<=>(const PathReference& other) const noexcept = default;
[[nodiscard]] bool empty() const noexcept { return adapter_ == nullptr; }
[[nodiscard]] class FileSystemAdapter* getAdapter() const noexcept { return adapter_; }
[[nodiscard]] const fs::path& getPath() const noexcept { return path_; }
[[nodiscard]] inline FileInfo getInfo() const;