[vlc-commits] [Git][videolan/vlc][master] win32: filesystem: don't prepend \\*\ in relative path opendir
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Oct 22 10:11:42 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
e2ecc7d9 by Steve Lhomme at 2022-10-22T09:33:18+00:00
win32: filesystem: don't prepend \\*\ in relative path opendir
We should not have long pathes and it seems FindFirstFileExW() doesn't like it.
- - - - -
1 changed file:
- src/win32/filesystem.c
Changes:
=====================================
src/win32/filesystem.c
=====================================
@@ -212,23 +212,21 @@ vlc_DIR *vlc_opendir (const char *dirname)
char *wildcard;
const size_t len = strlen(dirname);
- if (p_dir->u.insert_dot_dot)
+ if (p_dir->u.insert_dot_dot || strncmp(dirname + 1, ":\\", 2) != 0)
{
// Prepending the string "\\?\" does not allow access to the root directory.
+ // Don't use long path with relative pathes.
wildcard = malloc(len + 3);
if (unlikely(wildcard == NULL))
{
free (p_dir);
return NULL;
}
- else
- {
- memcpy(wildcard, dirname, len);
- size_t j = len;
- wildcard[j++] = '\\';
- wildcard[j++] = '*';
- wildcard[j++] = '\0';
- }
+ memcpy(wildcard, dirname, len);
+ size_t j = len;
+ wildcard[j++] = '\\';
+ wildcard[j++] = '*';
+ wildcard[j++] = '\0';
}
else
{
@@ -238,28 +236,26 @@ vlc_DIR *vlc_opendir (const char *dirname)
free (p_dir);
return NULL;
}
- else
+
+ // prepend "\\?\"
+ wildcard[0] = '\\';
+ wildcard[1] = '\\';
+ wildcard[2] = '?';
+ wildcard[3] = '\\';
+ size_t j = 4;
+ for (size_t i=0; i<len;i++)
{
- // prepend "\\?\"
- wildcard[0] = '\\';
- wildcard[1] = '\\';
- wildcard[2] = '?';
- wildcard[3] = '\\';
- size_t j = 4;
- for (size_t i=0; i<len;i++)
- {
- // remove forward slashes from long pathes to please FindFirstFileExW
- if (unlikely(dirname[i] == '/'))
- wildcard[j++] = '\\';
- else
- wildcard[j++] = dirname[i];
- }
- // append "\*" or "*"
- if (wildcard[j-1] != '\\')
+ // remove forward slashes from long pathes to please FindFirstFileExW
+ if (unlikely(dirname[i] == '/'))
wildcard[j++] = '\\';
- wildcard[j++] = '*';
- wildcard[j++] = '\0';
+ else
+ wildcard[j++] = dirname[i];
}
+ // append "\*" or "*"
+ if (wildcard[j-1] != '\\')
+ wildcard[j++] = '\\';
+ wildcard[j++] = '*';
+ wildcard[j++] = '\0';
}
p_dir->wildcard = ToWide(wildcard);
free(wildcard);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e2ecc7d920aae0808aae6b4f92a5428d2b058e46
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e2ecc7d920aae0808aae6b4f92a5428d2b058e46
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list