diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -1448,17 +1448,39 @@ nsLocalFile::CopySingleFile(nsIFile *sou copyOK = ::CopyFileW(filePath.get(), destPath.get(), PR_TRUE); else { #ifndef WINCE copyOK = ::MoveFileExW(filePath.get(), destPath.get(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH); #else - DeleteFile(destPath.get()); + /* create local file for destPath */ + + nsCOMPtr realDest = new nsLocalFile(); + if (realDest == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + + rv = realDest->InitWithPath(destPath); + + if (NS_FAILED(rv)) + return rv; + + /* + PRBool isdir; + if (realDest->IsDirectory(&isdir)) + ::RemoveDirectoryW(destPath.get()); + else + ::DeleteFileW(destPath.get()); + */ + rv = realDest->Remove(PR_TRUE); + + if (NS_FAILED(rv)) + return rv; + copyOK = :: MoveFileW(filePath.get(), destPath.get()); #endif } if (!copyOK) // CopyFile and MoveFileEx return zero at failure. rv = ConvertWinError(GetLastError()); #ifndef WINCE