if (! target.Exists() )
if(replacementFile == doomedFile) {  return result; }  doomedFile.Delete(false);  if (! doomedFile.Exists() )
REGERR ReplaceFileLater(nsFileSpec& tmpfile, nsFileSpec& target ){    REGERR result = 0;        if (! target.Exists() )    {        // Now that we have move the existing file, we can move the mExtracedFile into place.        nsFileSpec parentofFinalFile;        target.GetParent(parentofFinalFile);        result = tmpfile.Move(parentofFinalFile);            char* leafName = target.GetLeafName();        tmpfile.Rename(leafName);        nsCRT::free(leafName);    }    else    {        RKEY newkey;        HREG reg;        if ( REGERR_OK == NR_RegOpen("", &reg) )         {            result = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey);            if ( result == REGERR_OK )             {                nsPersistentFileDescriptor tempDesc(tmpfile);                nsPersistentFileDescriptor targDesc(target);                            char* tempBuffer = nsnull;                char* targBuffer = nsnull;                nsOutputStringStream tempStream(tempBuffer);                nsOutputStringStream targStream(targBuffer);                            tempStream << tempDesc;                targStream << targDesc;                result = NR_RegSetEntry( reg, newkey, tempBuffer, REGTYPE_ENTRY_BYTES, targBuffer, strlen(targBuffer));                if (result == REGERR_OK)                    result = nsInstall::REBOOT_NEEDED;                        }            NR_RegClose(reg);        }    }    return result;}