Definition (normalised file name). A normalised file name is a string subject to the following restrictions. The maximum substrings not containing "/" are called components. Components of the form "", "." and ".." are called special components. A file name is either absolute or relative. An normalised absolute file name is either "/", or starts with an empty component followed by one or more non-special components. A normalised relative file name is either ".", or it starts with zero or more "..", followed by zero or more non-special components, but adding up to at least one component.
NFN ::= relative_NFN | absolute_NFN relative_NFN ::= "." | "../"* ".." | "../"* (non_special_comp "/")* non_special_comp absolute_NFN ::= "/" | ("/" non_special_comp)+
cu_bool_t cuos_is_path_charr | ( | char const * | s, | |
size_t | len | |||
) |
True iff the string from s to s + len is a normalised file name.
cu_bool_t cuos_is_path_cstr | ( | char const * | s | ) |
True iff s is a normalised file name.
cu_bool_t cuos_is_pathcomp_charr | ( | char const * | s, | |
size_t | len | |||
) |
True iff the string from s to s + len is valid as a non-special path component. See note under cuos_is_pathcomp_str.
cu_bool_t cuos_is_pathcomp_cstr | ( | char const * | s | ) |
True iff s is valid as a non-special path component. See note under cuos_is_pathcomp_str.
True iff str is valid as a non-special path component.
Given that path0 and path1 are normalised file names, if path1 is absolute, return path1, else return the normalised file name of path1 relative to path0, i.e. the normalisation of the concatenation of (path0, "/", path1). path1 must be non-empty.
cu_str_t cuos_path_cat2_cc | ( | char const * | path0, | |
char const * | path1 | |||
) |
As cuos_path_cat2 but with 2 C string arguments.
As cuos_path_cat2 but with C string as first argument.
As cuos_path_cat2 but with C string as second argument.
int cuos_path_component_count | ( | cu_str_t | path | ) |
Return the number of components of path, where "." counts as zero and other components, including a leading "/" counts as one.
int cuos_path_depth | ( | cu_str_t | path | ) |
Returns the depth of path, where each non-special component and a leading "/" counts as one, "." counts as zero, and ".." counts as -1.
Returns extension of path, including the ".", or an empty string if path has no extension.
True iff path ends with the substring from s to s + n.
cu_str_t cuos_path_from_charr | ( | char const * | s, | |
size_t | len | |||
) |
Create normalised file names from the string from s to s + len or NULL
if it is not a valid file name.
cu_str_t cuos_path_from_cstr | ( | char const * | s | ) |
Returns a normalised file name from s, or NULL
if s does not hold a valid file name.
Returns a normalised file name from str, or NULL
if str does not hold a valid file name.
True iff path has no components, i.e. it is ".". This is faster than using cuos_path_component_count.
Returns path without its extension or path itself if it has no extension.
If pos ≥ 0, then split path before component pos and store the first and last parts as a normalised file names in *path0
and *path1
, respectively. If pos < 0, the call is equivalent to one where pos is replaced by n + pos, where n is the number of components.