Bug 1007797 - Save ctypes.winLastError to prevent WinFile.GetFileAttributes from clobbering it. r=yoric

This commit is contained in:
Masatoshi Kimura committed 2014-05-12 22:46:49 +09:00
1 parent 69a554f909
commit 12242164d0
1 file changed
+6 -2
@@ -414,9 +414,13 @@
return;
}
} else if (ctypes.winLastError == Const.ERROR_ACCESS_DENIED) {
// Save winLastError before another ctypes call.
let lastError = ctypes.winLastError;
let attributes = WinFile.GetFileAttributes(path);
if (attributes != Const.INVALID_FILE_ATTRIBUTES &&
attributes & Const.FILE_ATTRIBUTE_READONLY) {
if (attributes != Const.INVALID_FILE_ATTRIBUTES) {
if (!(attributes & Const.FILE_ATTRIBUTE_READONLY)) {
throw new File.Error("remove", lastError, path);
}
let newAttributes = attributes & ~Const.FILE_ATTRIBUTE_READONLY;
if (WinFile.SetFileAttributes(path, newAttributes) &&
WinFile.DeleteFile(path)) {