return -1;
}
- /* Remove trailing directory separator, unless name is the root
- directory of a drive or UNC volume in which case ensure there
- is a trailing separator. */
len = strlen (name);
+ /* Allocate 1 extra byte so that we could append a slash to a root
+ directory, down below. */
name = strcpy (alloca (len + 2), name);
/* Avoid a somewhat costly call to is_symlink if the filesystem
}
else if (rootdir)
{
+ /* Make sure root directories end in a slash. */
if (!IS_DIRECTORY_SEP (name[len-1]))
strcat (name, "\\");
if (GetDriveType (name) < 2)
{
int have_wfd = -1;
+ /* Make sure non-root directories do NOT end in a slash,
+ otherwise FindFirstFile might fail. */
if (IS_DIRECTORY_SEP (name[len-1]))
name[len - 1] = 0;