path: Also accept / as directory separator on Windows
This adds helper functions to determine the first or last directory separator in a string and to check if a given character is a separator. Paths starting with a separator are now also considered absolute on Windows as these are rooted at the current drive. Note that it's fine to use DIRECTORY_SEPARATOR when combining strings as Windows API calls accept both forward and backward slashes as separators. Co-authored-by: Michał Skalski <[email protected]> References #3684.
This commit is contained in:
co-authored by
Michał Skalski
parent
3de65f8d67
commit
e6a6fc33b6
@@ -173,9 +173,9 @@ enumerator_t* enumerator_create_directory(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
/* append a '/' if not already done */
|
||||
if (this->full[len-1] != '/')
|
||||
if (!path_is_separator(this->full[len-1]))
|
||||
{
|
||||
this->full[len++] = '/';
|
||||
this->full[len++] = DIRECTORY_SEPARATOR[0];
|
||||
this->full[len] = '\0';
|
||||
}
|
||||
this->full_end = &this->full[len];
|
||||
|
||||
Reference in New Issue
Block a user