15#ifndef IOX2_BB_DETAIL_PATH_AND_FILE_VERIFIER_HPP
16#define IOX2_BB_DETAIL_PATH_AND_FILE_VERIFIER_HPP
72template <u
int64_t StringCapacity>
81template <u
int64_t StringCapacity>
86template <u
int64_t StringCapacity>
89template <u
int64_t StringCapacity>
95 if ((name == current_directory) || (name == parent_directory)) {
99 const auto name_size = name.size();
101 for (uint64_t i { 0 }; i < name_size; ++i) {
104 const char c { name.unchecked_access()[i] };
118 if ((!is_small_letter && !is_capital_letter) && (!is_number && !is_special_character)) {
123 if (name_size == 0) {
128 return !(name.unchecked_access()[name_size - 1] ==
'.');
131template <u
int64_t StringCapacity>
141template <u
int64_t StringCapacity>
148 if (!maybe_separator.has_value()) {
152 const auto& position = maybe_separator.value();
154 bool is_file_name_valid {
false };
155 auto sub_str = name.code_units().substr(position + 1, name.size());
156 if (sub_str.has_value()) {
160 bool is_path_valid {
false };
161 sub_str = name.code_units().substr(0, position);
162 if (sub_str.has_value()) {
163 const bool is_empty_path { sub_str->empty() };
165 is_path_valid = is_empty_path || is_path_to_directory_valid;
169 return is_path_valid && is_file_name_valid;
172template <u
int64_t StringCapacity>
181 auto remaining = name;
182 while (!remaining.empty()) {
185 if (separator_position.has_value()) {
186 const uint64_t position { separator_position.value() };
197 const auto guaranteed_substr = remaining.code_units().substr(0, position);
198 const auto& filename_to_verify = guaranteed_substr.value();
200 || ((filename_to_verify == current_directory)
201 || (filename_to_verify == parent_directory)) };
202 if (!is_valid_directory) {
207 auto sub_str = remaining.code_units().substr(position + 1, remaining.size());
208 if (sub_str.has_value()) {
209 remaining = *sub_str;
221template <u
int64_t StringCapacity>
227 const char last_character { *name.code_units().back_element() };
231 if (last_character == separator) {
static auto from_utf8_unchecked(char const (&utf8_str)[M]) noexcept -> StaticString
constexpr char ASCII_CAPITAL_Z
constexpr char ASCII_CAPITAL_A
auto is_valid_path_to_directory(const bb::StaticString< StringCapacity > &name) noexcept -> bool
returns true if the provided name is a valid path, otherwise false
constexpr char ASCII_UNDERSCORE
auto is_valid_path_entry(const bb::StaticString< StringCapacity > &name, RelativePathComponents relative_path_components) noexcept -> bool
checks if the given string is a valid path entry. A path entry is the string between two path separat...
constexpr char ASCII_COLON
auto is_valid_path_to_file(const bb::StaticString< StringCapacity > &name) noexcept -> bool
verifies if the given string is a valid path to a file
constexpr char ASCII_DASH
auto is_valid_file_name(const bb::StaticString< StringCapacity > &name) noexcept -> bool
checks if the given string is a valid filename. It must fulfill the requirements of a valid path entr...
auto does_end_with_path_separator(const bb::StaticString< StringCapacity > &name) noexcept -> bool
returns true if the provided name ends with a path separator, otherwise false