-const tchar *
-path_basename_with_len(const tchar *path, size_t len)
-{
- const tchar *p = &path[len] - 1;
-
- /* 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;
-}
-
-/* Like the basename() function, but does not modify @path; it just returns a
- * pointer to it. */
-const tchar *
-path_basename(const tchar *path)
-{
- return path_basename_with_len(path, tstrlen(path));
-}
-
-/*
- * 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;
-}