BLI_path: add BLI_path_is_win32_drive_only check
This commit is contained in:
@@ -42,6 +42,7 @@ bool BLI_path_name_at_index(const char *__restrict path,
|
||||
bool BLI_path_is_unc(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
bool BLI_path_is_win32_drive(const char *path);
|
||||
bool BLI_path_is_win32_drive_only(const char *path);
|
||||
bool BLI_path_is_win32_drive_with_slash(const char *path);
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -307,7 +307,7 @@ static bool dir_create_recursive(char *dirname, int len)
|
||||
*dirname_parent_end = '\0';
|
||||
#ifdef WIN32
|
||||
/* Check special case `c:\foo`, don't try create `c:`, harmless but unnecessary. */
|
||||
if (dirname[0] && !(isalpha(dirname[0]) && (dirname[1] == ':') && dirname[2] == '\0'))
|
||||
if (dirname[0] && !BLI_path_is_win32_drive_only(dirname))
|
||||
#endif
|
||||
{
|
||||
const int mode = BLI_exists(dirname);
|
||||
|
||||
@@ -568,6 +568,11 @@ bool BLI_path_is_win32_drive(const char *path)
|
||||
return isalpha(path[0]) && (path[1] == ':');
|
||||
}
|
||||
|
||||
bool BLI_path_is_win32_drive_only(const char *path)
|
||||
{
|
||||
return isalpha(path[0]) && (path[1] == ':') && (path[2] == '\0');
|
||||
}
|
||||
|
||||
bool BLI_path_is_win32_drive_with_slash(const char *path)
|
||||
{
|
||||
return isalpha(path[0]) && (path[1] == ':') && ELEM(path[2], '\\', '/');
|
||||
|
||||
@@ -2759,9 +2759,9 @@ static void file_expand_directory(bContext *C)
|
||||
{
|
||||
BLI_windows_get_default_root_dir(params->dir);
|
||||
}
|
||||
/* change "C:" --> "C:\", #28102. */
|
||||
else if ((isalpha(params->dir[0]) && (params->dir[1] == ':')) && (params->dir[2] == '\0')) {
|
||||
params->dir[2] = '\\';
|
||||
/* Change `C:` --> `C:\`, #28102. */
|
||||
else if (BLI_path_is_win32_drive_only(params->dir)) {
|
||||
params->dir[2] = SEP;
|
||||
params->dir[3] = '\0';
|
||||
}
|
||||
else if (BLI_path_is_unc(params->dir)) {
|
||||
|
||||
Reference in New Issue
Block a user