-/* Takes in a path of length @len in @buf, and transforms it into a string for
- * the path of its parent directory. */
-void
-to_parent_name(tchar *buf, size_t len)
-{
- ssize_t i = (ssize_t)len - 1;
- while (i >= 0 && buf[i] == T('/'))
- i--;
- while (i >= 0 && buf[i] != T('/'))
- i--;
- while (i >= 0 && buf[i] == T('/'))
- i--;
- buf[i + 1] = T('\0');
-}
-
-/* Like the basename() function, but does not modify @path; it just returns a
- * pointer to it. */
-const tchar *
-path_basename(const tchar *path)
-{
- const tchar *p = path;
- while (*p)
- p++;
- p--;
-
- /* Trailing slashes. */
- while (1) {
- if (p == path - 1)
- return T("");
- if (*p != T('/'))
- break;
- p--;
- }
-
- while ((p != path - 1) && *p != T('/'))
- p--;
-
- return p + 1;
-}
-
-/*
- * Returns a pointer to the part of @path following the first colon in the last
- * path component, or NULL if the last path component does not contain a colon.
- */
-const tchar *
-path_stream_name(const tchar *path)
-{
- const tchar *base = path_basename(path);
- const tchar *stream_name = tstrchr(base, T(':'));
- if (!stream_name)
- return NULL;
- else
- return stream_name + 1;
-}
-
-/*
- * Splits a file path into the part before the first '/', or the entire name if
- * there is no '/', and the part after the first sequence of '/' characters.
- *
- * @path: The file path to split.
- * @first_part_len_ret: A pointer to a `size_t' into which the length of the
- * first part of the path will be returned.
- * @return: A pointer to the next part of the path, after the first
- * sequence of '/', or a pointer to the terminating
- * null byte in the case of a path without any '/'.
- */
-const tchar *
-path_next_part(const tchar *path, size_t *first_part_len_ret)
-{
- size_t i;
- const tchar *next_part;
-
- i = 0;
- while (path[i] != T('/') && path[i] != T('\0'))
- i++;
- if (first_part_len_ret)
- *first_part_len_ret = i;
- next_part = &path[i];
- while (*next_part == T('/'))
- next_part++;
- return next_part;
-}
-
-/* Returns the number of components of @path. */
-int
-get_num_path_components(const char *path)
-{
- int num_components = 0;
- while (*path) {
- while (*path == '/')
- path++;
- if (*path)
- num_components++;
- while (*path && *path != '/')
- path++;
- }
- return num_components;
-}
-