os_scandir: fname_case -> path_fix_case

Use os_scandir().

fname_case() only gets used when `defined(USE_FNAME_CASE)` (on operating
systems with case-insensitive file systems), but may be useful in other
contexts, so move it to path.c. (See the TODO.)

Remove the unused parameter, len.
This commit is contained in:
Scott Prager
2014-09-20 22:39:31 -04:00
committed by Thiago de Arruda
parent 24da0d49d0
commit 0f4976687d
6 changed files with 60 additions and 63 deletions

View File

@@ -69,62 +69,6 @@ static int selinux_enabled = -1;
# include "os_unix.c.generated.h"
#endif
#if defined(USE_FNAME_CASE)
/*
* Set the case of the file name, if it already exists. This will cause the
* file name to remain exactly the same.
* Only required for file systems where case is ignored and preserved.
*/
void fname_case(
char_u *name,
int len /* buffer size, only used when name gets longer */
)
{
char_u *slash, *tail;
DIR *dirp;
struct dirent *dp;
FileInfo file_info;
if (os_fileinfo_link((char *)name, &file_info)) {
/* Open the directory where the file is located. */
slash = vim_strrchr(name, '/');
if (slash == NULL) {
dirp = opendir(".");
tail = name;
} else {
*slash = NUL;
dirp = opendir((char *)name);
*slash = '/';
tail = slash + 1;
}
if (dirp != NULL) {
while ((dp = readdir(dirp)) != NULL) {
/* Only accept names that differ in case and are the same byte
* length. TODO: accept different length name. */
if (STRICMP(tail, dp->d_name) == 0
&& STRLEN(tail) == STRLEN(dp->d_name)) {
char_u newname[MAXPATHL + 1];
/* Verify the inode is equal. */
STRLCPY(newname, name, MAXPATHL + 1);
STRLCPY(newname + (tail - name), dp->d_name,
MAXPATHL - (tail - name) + 1);
FileInfo file_info_new;
if (os_fileinfo_link((char *)newname, &file_info_new)
&& os_fileinfo_id_equal(&file_info, &file_info_new)) {
STRCPY(tail, dp->d_name);
break;
}
}
}
closedir(dirp);
}
}
}
#endif
#if defined(HAVE_ACL)
# ifdef HAVE_SYS_ACL_H
# include <sys/acl.h>