]> wimlib.net Git - wimlib/blobdiff - src/util.c
Encodings update (IN PROGRESS)
[wimlib] / src / util.c
index bd377204a837bd6357ac0970383b307034e0b6bd..1e26a6f4349b74dd40c3570e99f707b729629b76 100644 (file)
@@ -501,15 +501,10 @@ to_parent_name(tchar *buf, size_t len)
        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)
+path_basename_with_len(const tchar *path, size_t len)
 {
-       const tchar *p = path;
-       while (*p)
-               p++;
-       p--;
+       const tchar *p = &path[len] - 1;
 
        /* Trailing slashes. */
        while (1) {
@@ -526,6 +521,14 @@ path_basename(const tchar *path)
        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.