Fix the Win32_rename() function so it correctly

returns an error code. Use the same code in Win9X
and NT.

Fix some ca.c options so they work under Win32:
unlink/rename wont work under Win32 unless the file
is closed.
This commit is contained in:
Dr. Stephen Henson 2002-03-08 19:11:15 +00:00
parent 4882171df5
commit 26e1237380
2 changed files with 11 additions and 10 deletions

View File

@ -333,16 +333,13 @@ void program_name(char *in, char *out, int size)
#ifdef OPENSSL_SYS_WIN32 #ifdef OPENSSL_SYS_WIN32
int WIN32_rename(char *from, char *to) int WIN32_rename(char *from, char *to)
{ {
#ifdef OPENSSL_SYS_WINNT /* Windows rename gives an error if 'to' exists, so delete it
int ret; * first and ignore file not found errror
/* Note: MoveFileEx() doesn't work under Win95, Win98 */ */
if((remove(to) != 0) && (errno != ENOENT))
ret=MoveFileEx(from,to,MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED); return -1;
return(ret?0:-1); #undef rename
#else return rename(from, to);
unlink(to);
return MoveFile(from, to);
#endif
} }
#endif #endif

View File

@ -1581,6 +1581,10 @@ bad:
#else #else
strcat(buf[1],"-old"); strcat(buf[1],"-old");
#endif #endif
BIO_free(in);
in = NULL;
BIO_free(out);
out = NULL;
if (rename(dbfile,buf[1]) < 0) if (rename(dbfile,buf[1]) < 0)
{ {
BIO_printf(bio_err,"unable to rename %s to %s\n", dbfile, buf[1]); BIO_printf(bio_err,"unable to rename %s to %s\n", dbfile, buf[1]);