diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-04-26 18:23:49 +0200 |
---|---|---|
committer | Stefan Hoffmann <stefan991@gmail.com> | 2014-05-09 15:49:33 +0200 |
commit | 902ad8d94d9a1eafde858793587037e620c6ee6f (patch) | |
tree | e2dd0405439b1e2a703a3949729d12215dc7e032 /src/fileio.c | |
parent | a080819c3ef93c41a0bbd14b3c5f76d26bb9d404 (diff) | |
download | rneovim-902ad8d94d9a1eafde858793587037e620c6ee6f.tar.gz rneovim-902ad8d94d9a1eafde858793587037e620c6ee6f.tar.bz2 rneovim-902ad8d94d9a1eafde858793587037e620c6ee6f.zip |
replaced some mch_stat() with os_get_file_info()
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/fileio.c b/src/fileio.c index d7ee26297c..b692f38c3d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4813,12 +4813,11 @@ int vim_rename(char_u *from, char_u *to) int n; char *errmsg = NULL; char *buffer; - struct stat st; long perm; #ifdef HAVE_ACL vim_acl_T acl; /* ACL from original file */ #endif - int use_tmp_file = FALSE; + bool use_tmp_file = false; /* * When the names are identical, there is nothing to do. When they refer @@ -4827,30 +4826,25 @@ int vim_rename(char_u *from, char_u *to) */ if (fnamecmp(from, to) == 0) { if (p_fic && STRCMP(path_tail(from), path_tail(to)) != 0) - use_tmp_file = TRUE; + use_tmp_file = true; else return 0; } - /* - * Fail if the "from" file doesn't exist. Avoids that "to" is deleted. - */ - if (mch_stat((char *)from, &st) < 0) + // Fail if the "from" file doesn't exist. Avoids that "to" is deleted. + FileInfo from_info; + if (!os_get_file_info((char *)from, &from_info)) { return -1; + } -#ifdef UNIX - { - struct stat st_to; - - /* It's possible for the source and destination to be the same file. - * This happens when "from" and "to" differ in case and are on a FAT32 - * filesystem. In that case go through a temp file name. */ - if (mch_stat((char *)to, &st_to) >= 0 - && st.st_dev == st_to.st_dev - && st.st_ino == st_to.st_ino) - use_tmp_file = TRUE; + // It's possible for the source and destination to be the same file. + // This happens when "from" and "to" differ in case and are on a FAT32 + // filesystem. In that case go through a temp file name. + FileInfo to_info; + if (os_get_file_info((char *)to, &to_info) + && os_file_info_id_equal(&from_info, &to_info)) { + use_tmp_file = true; } -#endif if (use_tmp_file) { char_u tempname[MAXPATHL + 1]; |