From: Ian Lance Taylor Date: Thu, 6 May 1999 11:03:33 +0000 (+0000) Subject: * rename.c (smart_rename): Fix test of whether file exists. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82716b788e14918184e99a7ef97721fa87315959;p=binutils-gdb.git * rename.c (smart_rename): Fix test of whether file exists. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 6f19b862c6a..b61c92128a6 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +1999-05-06 Ian Lance Taylor + + * rename.c (smart_rename): Fix test of whether file exists. + 1999-05-06 Nick Clifton * objdump.c (disassemble_data): Set display_endian based on target diff --git a/binutils/rename.c b/binutils/rename.c index fdc7263d1fc..f8314fbd095 100644 --- a/binutils/rename.c +++ b/binutils/rename.c @@ -139,17 +139,17 @@ smart_rename (from, to, preserve_dates) const char *to; int preserve_dates; { - int exists; + boolean exists; struct stat s; int ret = 0; - exists = lstat (to, &s); + exists = lstat (to, &s) == 0; #if defined (_WIN32) && !defined (__CYGWIN32__) /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but fail instead. Also, chown is not present. */ - if (exists == 0) + if (exists) remove (to); ret = rename (from, to); @@ -163,7 +163,7 @@ smart_rename (from, to, preserve_dates) #else /* Use rename only if TO is not a symbolic link and has only one hard link. */ - if (exists < 0 || (!S_ISLNK (s.st_mode) && s.st_nlink == 1)) + if (! exists || (!S_ISLNK (s.st_mode) && s.st_nlink == 1)) { ret = rename (from, to); if (ret == 0)