Sfoglia il codice sorgente

stb.h: stb_splitpath correctly handles relative paths with explicit drive specifiers

Sean Barrett 3 anni fa
parent
commit
ef861421e2
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      deprecated/stb.h

+ 6 - 0
deprecated/stb.h

@@ -2423,6 +2423,12 @@ static char *stb__splitpath_raw(char *buffer, char *path, int flag)
    char *s = stb_strrchr2(path, '/', '\\');
    char *s = stb_strrchr2(path, '/', '\\');
    char *t = strrchr(path, '.');
    char *t = strrchr(path, '.');
    if (s && t && t < s) t = NULL;
    if (s && t && t < s) t = NULL;
+
+   if (!s) {
+      // check for drive
+      if (isalpha(path[0]) && path[1] == ':')
+         s = &path[1];
+   }
    if (s) ++s;
    if (s) ++s;
 
 
    if (flag == STB_EXT_NO_PERIOD)
    if (flag == STB_EXT_NO_PERIOD)