diff options
Diffstat (limited to 'kernel/include/kernel/filesystem/path.hpp')
| -rw-r--r-- | kernel/include/kernel/filesystem/path.hpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/kernel/include/kernel/filesystem/path.hpp b/kernel/include/kernel/filesystem/path.hpp deleted file mode 100644 index 4845bf1a..00000000 --- a/kernel/include/kernel/filesystem/path.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP -#define TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP - -#include <kernel/filesystem/constants.hpp> - -#include <kstd/string> - -#include <ranges> -#include <string_view> - -namespace kernel::filesystem::path -{ - /** - @brief Provides utilities for handling filesystem paths, including validation and splitting into components. - */ - - /** - @brief Checks if the given path is within the maximum allowed length. - @param path The path to check. - @return true if the path length is valid, false otherwise. - */ - auto inline is_valid_path_length(std::string_view path) -> bool - { - return path.length() < kernel::filesystem::constants::max_path_length; - } - - /** - @brief Checks if the given path is a valid absolute path (starts with '/'). - @param path The path to check. - @return true if the path is a valid absolute path, false otherwise. - */ - auto inline is_valid_absolute_path(std::string_view path) -> bool - { - return !path.empty() && path.front() == '/' && is_valid_path_length(path); - } - - /** - @brief Checks if the given path is a valid relative path (doesn't start with '/'). - @param path The path to check. - @return true if the path is a valid relative path, false otherwise. - */ - auto inline is_valid_relative_path(std::string_view path) -> bool - { - return !path.empty() && path.front() != '/' && is_valid_path_length(path); - } - - /** - @brief Checks if the given path is a valid path (either absolute or relative). - @param path The path to check. - @return true if the path is a valid path, false otherwise. - */ - auto inline is_valid_path(std::string_view path) -> bool - { - return is_valid_absolute_path(path) || is_valid_relative_path(path); - } - - /** - @brief Splits the given path into its components. - @param path The path to split. - @return A range of strings representing the components of the path. - */ - auto inline split(std::string_view path) - { - return std::views::split(path, '/') | std::views::filter([](auto const & part) { return !part.empty(); }) | - std::views::transform( - [](auto const & part) { return kstd::string(std::string_view(part.begin(), part.end())); }); - } - -} // namespace kernel::filesystem::path - -#endif // TEACH_OS_KERNEL_FILESYSTEM_PATH_HPP
\ No newline at end of file |
