diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-12-10 20:17:30 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-12-10 20:17:30 +0000 |
commit | 24552beda0124d51735b2dd5a0352cb81a196d14 (patch) | |
tree | 834dcfbf6021c4ad939627b7d7509200ede7d6a4 /src | |
parent | 43abc52195744330e1df8f50bda64c1f66f9b507 (diff) | |
download | vim-git-24552beda0124d51735b2dd5a0352cb81a196d14.tar.gz |
updated for version 7.0166
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 66 | ||||
-rw-r--r-- | src/os_unix.h | 3 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 7d2d0cc9e..4535aef47 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2354,6 +2354,72 @@ mch_isFullName(fname) #endif } +#if defined(USE_FNAME_CASE) || defined(PROTO) +/* + * 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 ingored and preserved. + */ +/*ARGSUSED*/ + void +fname_case(name, len) + char_u *name; + int len; /* buffer size, only used when name gets longer */ +{ + struct stat st; + char_u *slash, *tail; + DIR *dirp; + struct dirent *dp; + + if (lstat((char *)name, &st) >= 0) + { + /* 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]; + struct stat st2; + + /* Verify the inode is equal. */ + vim_strncpy(newname, name, MAXPATHL); + vim_strncpy(newname + (tail - name), (char_u *)dp->d_name, + MAXPATHL - (tail - name)); + if (lstat((char *)newname, &st2) >= 0 + && st.st_ino == st2.st_ino + && st.st_dev == st2.st_dev) + { + STRCPY(tail, dp->d_name); + break; + } + } + } + + closedir(dirp); + } + } +} +#endif + /* * Get file permissions for 'name'. * Returns -1 when it doesn't exist. diff --git a/src/os_unix.h b/src/os_unix.h index b78b23e7b..c1458d66e 100644 --- a/src/os_unix.h +++ b/src/os_unix.h @@ -40,6 +40,9 @@ #if defined(__CYGWIN__) || defined(__CYGWIN32__) # define WIN32UNIX /* Compiling for Win32 using Unix files. */ # define BINARY_FILE_IO + +# define CASE_INSENSITIVE_FILENAME +# define USE_FNAME_CASE /* Fix filename case differences. */ #endif /* On AIX 4.2 there is a conflicting prototype for ioctl() in stropts.h and |