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/ex_cmds.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/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index c2c3b6631d..3613a02cb3 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1496,9 +1496,6 @@ void write_viminfo(char_u *file, int forceit) #if defined(UNIX) mode_t umask_save; #endif -#ifdef UNIX - struct stat st_old; /* mch_stat() of existing viminfo file */ -#endif if (no_viminfo()) return; @@ -1535,16 +1532,15 @@ void write_viminfo(char_u *file, int forceit) * overwrite a user's viminfo file after a "su root", with a * viminfo file that the user can't read. */ - st_old.st_dev = (dev_t)0; - st_old.st_ino = 0; - st_old.st_mode = 0600; - if (mch_stat((char *)fname, &st_old) == 0 + + FileInfo old_info; // FileInfo of existing viminfo file + if (os_get_file_info((char *)fname, &old_info) && getuid() != ROOT_UID - && !(st_old.st_uid == getuid() - ? (st_old.st_mode & 0200) - : (st_old.st_gid == getgid() - ? (st_old.st_mode & 0020) - : (st_old.st_mode & 0002)))) { + && !(old_info.stat.st_uid == getuid() + ? (old_info.stat.st_mode & 0200) + : (old_info.stat.st_gid == getgid() + ? (old_info.stat.st_mode & 0020) + : (old_info.stat.st_mode & 0002)))) { int tt = msg_didany; /* avoid a wait_return for this message, it's annoying */ @@ -1596,7 +1592,7 @@ void write_viminfo(char_u *file, int forceit) umask_save = umask(0); fd = mch_open((char *)tempname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, - (int)((st_old.st_mode & 0777) | 0600)); + (int)((old_info.stat.st_mode & 0777) | 0600)); (void)umask(umask_save); # else fd = mch_open((char *)tempname, @@ -1622,8 +1618,9 @@ void write_viminfo(char_u *file, int forceit) * Make sure the owner can read/write it. This only works for * root. */ - if (fp_out != NULL) - ignored = fchown(fileno(fp_out), st_old.st_uid, st_old.st_gid); + if (fp_out != NULL) { + fchown(fileno(fp_out), old_info.stat.st_uid, old_info.stat.st_gid); + } #endif } } |