mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Convert extended UNC paths to standard UNC format in windows_realpath
This commit is contained in:
parent
f9626f6e3e
commit
f48e406d52
1 changed files with 12 additions and 3 deletions
15
os/mingw.c
15
os/mingw.c
|
|
@ -2047,9 +2047,18 @@ char* windows_realpath(const char* path, char* resolved_path)
|
|||
|
||||
resolved_path = u16tou8(resolved_path, conv_buf);
|
||||
|
||||
/* Windows prefixes paths with "\\?\" (UNC). Skip it if you want a standard path */
|
||||
if (strncmp(resolved_path, "\\\\?\\", 4) == 0) {
|
||||
memmove(resolved_path, resolved_path + 4, strlen(resolved_path) - 3);
|
||||
/*
|
||||
* Windows prefixes normalized paths with "\\?\" (for local drives)
|
||||
* or "\\?\UNC\" (for network shares). Convert them to standard format.
|
||||
*/
|
||||
if (strncmp(resolved_path, "\\\\?\\UNC\\", 8) == 0) {
|
||||
/* replace "\\?\UNC\" with "\\" */
|
||||
resolved_path[0] = '\\';
|
||||
resolved_path[1] = '\\';
|
||||
memmove(resolved_path + 2, resolved_path + 8, strlen(resolved_path + 8) + 1);
|
||||
} else if (strncmp(resolved_path, "\\\\?\\", 4) == 0) {
|
||||
/* skip "\\?\" */
|
||||
memmove(resolved_path, resolved_path + 4, strlen(resolved_path + 4) + 1);
|
||||
}
|
||||
|
||||
return resolved_path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue