mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
Replace use of mch_rename with rename.
The macro mch_rename is no longer necessary, because C99 function rename is always available.
This commit is contained in:

committed by
Thiago de Arruda

parent
c30c9b275c
commit
c298edd5dc
12
src/fileio.c
12
src/fileio.c
@@ -5072,12 +5072,12 @@ int vim_rename(char_u *from, char_u *to)
|
||||
for (n = 123; n < 99999; ++n) {
|
||||
sprintf((char *)gettail((char_u *)tempname), "%d", n);
|
||||
if (mch_stat(tempname, &st) < 0) {
|
||||
if (mch_rename((char *)from, tempname) == 0) {
|
||||
if (mch_rename(tempname, (char *)to) == 0)
|
||||
if (rename((char *)from, tempname) == 0) {
|
||||
if (rename(tempname, (char *)to) == 0)
|
||||
return 0;
|
||||
/* Strange, the second step failed. Try moving the
|
||||
* file back and return failure. */
|
||||
mch_rename(tempname, (char *)from);
|
||||
rename(tempname, (char *)from);
|
||||
return -1;
|
||||
}
|
||||
/* If it fails for one temp name it will most likely fail
|
||||
@@ -5090,8 +5090,8 @@ int vim_rename(char_u *from, char_u *to)
|
||||
|
||||
/*
|
||||
* Delete the "to" file, this is required on some systems to make the
|
||||
* mch_rename() work, on other systems it makes sure that we don't have
|
||||
* two files when the mch_rename() fails.
|
||||
* rename() work, on other systems it makes sure that we don't have
|
||||
* two files when the rename() fails.
|
||||
*/
|
||||
|
||||
mch_remove(to);
|
||||
@@ -5099,7 +5099,7 @@ int vim_rename(char_u *from, char_u *to)
|
||||
/*
|
||||
* First try a normal rename, return if it works.
|
||||
*/
|
||||
if (mch_rename((char *)from, (char *)to) == 0)
|
||||
if (rename((char *)from, (char *)to) == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user