Merge branch 'pb/submodule-update-fetches'
[git] / compat / win32 / path-utils.c
1 #include "../../git-compat-util.h"
2
3 int win32_skip_dos_drive_prefix(char **path)
4 {
5         int ret = has_dos_drive_prefix(*path);
6         *path += ret;
7         return ret;
8 }
9
10 int win32_offset_1st_component(const char *path)
11 {
12         char *pos = (char *)path;
13
14         /* unc paths */
15         if (!skip_dos_drive_prefix(&pos) &&
16                         is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {
17                 /* skip server name */
18                 pos = strpbrk(pos + 2, "\\/");
19                 if (!pos)
20                         return 0; /* Error: malformed unc path */
21
22                 do {
23                         pos++;
24                 } while (*pos && !is_dir_sep(*pos));
25         }
26
27         return pos + is_dir_sep(*pos) - path;
28 }