Class filesystem_resolver

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class legion::core::filesystem::filesystem_resolver : public legion::core::filesystem::filesystem_resolver_common_base

Abstract class that should represent and implement all functions of your filesystem, note in particular the pure virtual functions.

Subclassed by legion::core::filesystem::basic_resolver, legion::core::filesystem::mem_filesystem_resolver

Public Functions

filesystem_resolver() = default
filesystem_resolver(const filesystem_resolver&) = default
filesystem_resolver(filesystem_resolver&&) noexcept = default
filesystem_resolver &operator=(const filesystem_resolver&) = default
filesystem_resolver &operator=(filesystem_resolver&&) = default
virtual ~filesystem_resolver() = default
file_traits resolve(const std::string &path) noexcept

Gets all traits of a particular file.

Note

Same as calling set_target and then calling all the individual traits manually.

Return

file_traits All traits of the file bunched together.

Parameters
  • [in] path: The location identifier to the resource.

file_traits get_traits() noexcept

Gets all traits of a particular file.

Note

Same as getting all the individual traits manually.

Return

file_traits All traits of the file bunched together.

inline void set_identifier(const std::string &ident)

Sets the identifier of the filesystem.

Note

If this filesystem is nested it should be the path to the root of the fs otherwise it can be arbitrary.

Parameters
  • [in] ident: The identifier of the filesystem.

inline void set_target(const std::string &target)

Sets the target path of the resolver.

Parameters
  • [in] target: The location identifier to the resource.

virtual bool is_file() const noexcept = 0

Checks if target points to a file.

Note

(implementation details) Certain traits obviously overrule others. The progression here works like this:

  • if is_file cannot be directory

  • if is_directory cannot be written and cannot be read

  • if exists cannot be created and is valid

  • if exists and is file can be read

virtual bool is_directory() const noexcept = 0

Checks if target points to a directory.

virtual bool is_valid() const noexcept = 0

Checks if target points to a valid location.

virtual bool writeable() const noexcept = 0

Checks if the target location can be written to.

virtual bool readable() const noexcept = 0

Checks if the target location can be read from.

virtual bool creatable() const noexcept = 0

Checks if the target location can be created.

virtual bool exists() const noexcept = 0

Checks if the target location exists.

virtual std::set<std::string> ls() const noexcept = 0

Gets all entries in a directory or similar concept (assume -a).

Note

When not is_directory this should return an empty set. set_target

Return

A set of strings of entries at the current pointed at location.

common::result<basic_resource, fs_error> get() noexcept

Get the contents of the file pointed at.

Note

When not readable this should return an fs_error using Err(). set_target

Return

basic_resource wrapped in Ok() or fs_error wrapped in Err().

common::result<const basic_resource, fs_error> get() const noexcept
virtual common::result<basic_resource, fs_error> get(interfaces::implement_signal_t) noexcept = 0
virtual common::result<const basic_resource, fs_error> get(interfaces::implement_signal_t) const noexcept = 0
common::result<void, fs_error> set(const basic_resource &res)

Sets the contents of the file pointed at.

Note

When not writeable should do nothing and return false.

Note

When attempting to create a directory res must be empty.

Return

result<void,fs_error>, has_error == true when the file could not be read.

Parameters
  • [in] res: The resource you want to set at location. set_target

virtual common::result<void, fs_error> set(interfaces::implement_signal_t, const basic_resource &res) = 0
virtual void erase(interfaces::implement_signal_t) const noexcept = 0
inline const filesystem_traits &get_fs_traits() const
inline void inherit(filesystem_resolver &outer)
virtual filesystem_resolver *make() = 0

Required to create new instances of the provider, similar to a surrogate constructor if required arguments must be copied over.

inline const std::string &get_identifier() const

Gets the identifier of the filesystem for tl resolvers this is the same as the root-domains.

inline const std::string &get_target() const

Gets the targeted file of the filesystem.