mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Detects also forward slash when checking for the extended-length path format in Windows.
If the user specify it in the configuration file, it could happen to have it converted by path_import().
This commit is contained in:
parent
38e1f4e251
commit
2378de67dd
1 changed files with 14 additions and 3 deletions
17
mingw.c
17
mingw.c
|
|
@ -118,6 +118,14 @@ static char* u16tou8n(const wchar_t* src, size_t number_of_wchar, size_t* result
|
|||
return conv_utf8_buffer[conv_utf8];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the char is a forward or back slash.
|
||||
*/
|
||||
static int is_slash(char c)
|
||||
{
|
||||
return c == '/' || c == '\\';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a path to the Windows format.
|
||||
*
|
||||
|
|
@ -144,17 +152,20 @@ static wchar_t* convert_arg(const char* src, int only_if_required)
|
|||
|
||||
dst = conv_utf16_buffer[conv_utf16];
|
||||
|
||||
/* note that we always check for both / and \ because the path is blindly */
|
||||
/* converted to unix format by path_import() */
|
||||
|
||||
if (only_if_required && strlen(src) < 260 - 12) {
|
||||
/* it's a short path */
|
||||
/* 260 is the MAX_PATH, note that it includes the space for the terminating NUL */
|
||||
/* 12 is an additional space for filename, required when creating directory */
|
||||
|
||||
/* do nothing */
|
||||
} else if (src[0] == '\\' && src[1] == '\\' && src[2] == '?' && src[3] == '\\') {
|
||||
} else if (is_slash(src[0]) && is_slash(src[1]) && src[2] == '?' && is_slash(src[3])) {
|
||||
/* if it's already a '\\?\' path */
|
||||
|
||||
/* do nothing */
|
||||
} else if (src[0] == '\\' && src[1] == '\\') {
|
||||
} else if (is_slash(src[0]) && is_slash(src[1])) {
|
||||
/* if it is a UNC path, like '\\server' */
|
||||
|
||||
/* prefix with '\\?\UNC\' */
|
||||
|
|
@ -169,7 +180,7 @@ static wchar_t* convert_arg(const char* src, int only_if_required)
|
|||
|
||||
/* skip initial '\\' */
|
||||
src += 2;
|
||||
} else if (src[0] != 0 && src[1] == ':' && (src[2] == '\\' || src[2] == '/')) {
|
||||
} else if (src[0] != 0 && src[1] == ':' && is_slash(src[2])) {
|
||||
/* if it is a disk designator path, like 'D:\' or 'D:/' */
|
||||
|
||||
/* prefix with '\\?\' */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue