Commit 988757fe by Edward Thomson Committed by Patrick Steinhardt

path: rename function that detects end of filename

The function `only_spaces_and_dots` used to detect the end of the
filename on win32.  Now we look at spaces and dots _before_ the end of
the string _or_ a `:` character, which would signify a win32 alternate
data stream.

Thus, rename the function `ntfs_end_of_filename` to indicate that it
detects the (virtual) end of a filename, that any further characters
would be elided to the given path.
parent 4bae85c5
......@@ -1626,7 +1626,16 @@ GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size
return false;
}
GIT_INLINE(bool) only_spaces_and_dots(const char *path)
/*
* Windows paths that end with spaces and/or dots are elided to the
* path without them for backward compatibility. That is to say
* that opening file "foo ", "foo." or even "foo . . ." will all
* map to a filename of "foo". This function identifies spaces and
* dots at the end of a filename, whether the proper end of the
* filename (end of string) or a colon (which would indicate a
* Windows alternate data stream.)
*/
GIT_INLINE(bool) ntfs_end_of_filename(const char *path)
{
const char *c = path;
......@@ -1646,13 +1655,13 @@ GIT_INLINE(bool) verify_dotgit_ntfs_generic(const char *name, size_t len, const
if (name[0] == '.' && len >= dotgit_len &&
!strncasecmp(name + 1, dotgit_name, dotgit_len)) {
return !only_spaces_and_dots(name + dotgit_len + 1);
return !ntfs_end_of_filename(name + dotgit_len + 1);
}
/* Detect the basic NTFS shortname with the first six chars */
if (!strncasecmp(name, dotgit_name, 6) && name[6] == '~' &&
name[7] >= '1' && name[7] <= '4')
return !only_spaces_and_dots(name + 8);
return !ntfs_end_of_filename(name + 8);
/* Catch fallback names */
for (i = 0, saw_tilde = 0; i < 8; i++) {
......@@ -1674,7 +1683,7 @@ GIT_INLINE(bool) verify_dotgit_ntfs_generic(const char *name, size_t len, const
}
}
return !only_spaces_and_dots(name + i);
return !ntfs_end_of_filename(name + i);
}
GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment