mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-02 07:30:55 -08:00
In MSVC, rename does not delete an existing file.
This commit is contained in:
parent
7d9ac27dd7
commit
153c044bc8
1 changed files with 10 additions and 1 deletions
|
|
@ -17,6 +17,10 @@
|
|||
#include <string.h>
|
||||
#ifndef _MSC_VER
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# include <io.h>
|
||||
# define access _access
|
||||
# define F_OK 0
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_PWD_H
|
||||
|
|
@ -241,9 +245,14 @@ backup_fopen(const char *filename, const char *option)
|
|||
char backupfilename[MAXPATHLEN];
|
||||
|
||||
strcat(strcpy(backupfilename, filename), ".BAK");
|
||||
#ifdef _MSC_VER
|
||||
/* MSVC rename doesn't remove an existing file */
|
||||
if (access(backupfilename, F_OK) == 0 && unlink(backupfilename))
|
||||
FElibc_error("Cannot remove the file ~S", 1, make_simple_string(backupfilename));
|
||||
#endif
|
||||
if (rename(filename, backupfilename))
|
||||
FElibc_error("Cannot rename the file ~S to ~S.", 2,
|
||||
filename, backupfilename);
|
||||
make_simple_string(filename), make_simple_string(backupfilename));
|
||||
return fopen(filename, option);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue