X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwin32_apply.c;h=df74519ddc4dcfc0ca14cbb38e518b63ac9a30f1;hb=28ebd986920812c7f91f30a3f3783d1ab3c951d0;hp=9eb8bad005f9fa6b2ef23d4fcee6e5be835d2f25;hpb=06c208689d042c215bb9882232aabb0d98c01875;p=wimlib diff --git a/src/win32_apply.c b/src/win32_apply.c index 9eb8bad0..df74519d 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -158,15 +158,17 @@ error: static BOOL win32_delete_file_wrapper(const wchar_t *path) { - DWORD attrib; DWORD err; + DWORD attrib; if (DeleteFile(path)) return TRUE; err = GetLastError(); attrib = GetFileAttributes(path); - if (attrib & FILE_ATTRIBUTE_READONLY) { + if ((attrib != INVALID_FILE_ATTRIBUTES) && + (attrib & FILE_ATTRIBUTE_READONLY)) + { /* Try again with FILE_ATTRIBUTE_READONLY cleared. */ attrib &= ~FILE_ATTRIBUTE_READONLY; if (SetFileAttributes(path, attrib)) {