From a7f38ba565d2e7732027570cbe7c83fd88d50ca6 Mon Sep 17 00:00:00 2001 From: hobbs Date: Mon, 22 Apr 2002 22:51:19 +0000 Subject: * win/tclWinFCmd.c (DoDeleteFile): check return of setattr API calls in file deletion for correct Win32 API handling. --- win/tclWinFCmd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index ce53359..098a409 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFCmd.c,v 1.28 2002/03/24 11:41:51 vincentdarley Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.29 2002/04/22 22:51:19 hobbs Exp $ */ #include "tclWinInt.h" @@ -649,7 +649,7 @@ DoDeleteFile( Tcl_SetErrno(ENOENT); return TCL_ERROR; } - + if ((*tclWinProcs->deleteFileProc)(nativePath) != FALSE) { return TCL_OK; } @@ -666,13 +666,16 @@ DoDeleteFile( Tcl_SetErrno(EISDIR); } else if (attr & FILE_ATTRIBUTE_READONLY) { - (*tclWinProcs->setFileAttributesProc)(nativePath, + int res = (*tclWinProcs->setFileAttributesProc)(nativePath, attr & ~FILE_ATTRIBUTE_READONLY); - if ((*tclWinProcs->deleteFileProc)(nativePath) != FALSE) { + if ((res != 0) && ((*tclWinProcs->deleteFileProc)(nativePath) + != FALSE)) { return TCL_OK; } TclWinConvertError(GetLastError()); - (*tclWinProcs->setFileAttributesProc)(nativePath, attr); + if (res != 0) { + (*tclWinProcs->setFileAttributesProc)(nativePath, attr); + } } } } else if (Tcl_GetErrno() == ENOENT) { -- cgit v0.12