fix for bug 7329. Deleteting a file that doesn't exist should not invalidate the nsFileSpec.

This commit is contained in:
ducarroz%netscape.com 1999-05-29 21:27:16 +00:00
parent fa41e26a94
commit 211b73619b

View File

@ -849,17 +849,24 @@ void nsFileSpec::CreateDirectory(int /* unix mode */)
void nsFileSpec::Delete(PRBool inRecursive) const
//----------------------------------------------------------------------------------------
{
OSErr anErr;
nsresult& mutableError = const_cast<nsFileSpec*>(this)->mError;
if (inRecursive)
{
// MoreFilesExtras
mutableError = NS_FILE_RESULT(::DeleteDirectory(
anErr = ::DeleteDirectory(
mSpec.vRefNum,
mSpec.parID,
const_cast<unsigned char*>(mSpec.name)));
const_cast<unsigned char*>(mSpec.name));
}
else
mutableError = NS_FILE_RESULT(FSpDelete(&mSpec));
anErr = ::FSpDelete(&mSpec);
if (anErr == fnfErr) // deleting a file that doesn't exist isn't an error!
anErr = noErr;
mutableError = NS_FILE_RESULT(anErr);
} // nsFileSpec::Delete
//----------------------------------------------------------------------------------------