|
- #pragma once
-
- #include <string>
- #include <vector>
-
- #include "../misc.h"
-
- namespace cppfs
- {
-
- enum class path_status
- {
- none = 0,
- absoulte,
- relative,
- };
-
- struct path
- {
- public:
- using string_vector = std::vector<std::string>;
-
- public:
- /**
- * @brief Get the path of the current working directory.
- */
- static inline path current();
-
- private:
- path_status _status;
- mutable std::string _path;
- mutable string_vector _parts;
-
- public:
- /**
- * @brief Default construtor.
- */
- inline path();
-
- /**
- * @brief Value construtor.
- */
- inline path(const std::string& p_path);
-
- /**
- * @brief Value construtor.
- */
- inline path(
- string_vector&& p_parts,
- path_status p_status);
-
- /**
- * @brief Value construtor.
- */
- inline path(
- const string_vector& p_parts,
- path_status p_status = path_status::none);
-
- /**
- * @brief Value construtor.
- */
- inline path(
- const std::initializer_list<std::string>& p_parts,
- path_status p_status = path_status::none);
-
- /**
- * @brief Move constructor.
- */
- inline path(path&&) = default;
-
- /**
- * @brief Copy constructor.
- */
- inline path(const path&) = default;
-
- /**
- * @brief Move assignment constructor.
- */
- inline path& operator=(path&&) = default;
-
- /**
- * @brief Copy assignment constructor.
- */
- inline path& operator=(const path&) = default;
-
- public:
- /**
- * @brief Get the path status.
- */
- inline path_status status() const;
-
- /**
- * @brief Get the type of the path.
- */
- inline file_type type() const;
-
- /**
- * @brief Get the stored path as string.
- */
- inline const std::string& str() const;
-
- /**
- * @brief Get the parts of the path.
- */
- inline const string_vector& parts() const;
-
- /**
- * @brief Returns true if the path exists.
- */
- inline bool exsists() const;
-
- /**
- * @brief Returns true if the path is a normal file.
- */
- inline bool is_file() const;
-
- /**
- * @brief Returns true if the path is a normal directory.
- */
- inline bool is_directory() const;
-
- /**
- * @brief Returns the base path of the current stored path.
- */
- inline path base() const;
-
- /**
- * @brief Returns the normalized path.
- */
- inline path normalize() const;
-
- /**
- * @brief Returns file extension.
- */
- inline std::string extension() const;
-
- /**
- * @brief Combines two paths.
- */
- inline path join(const path& other) const;
-
- private:
- /**
- * @brief Create a path from the parts vector.
- */
- std::string make_path() const;
- };
-
- }
|