diff --git a/GpApp/FileError.cpp b/GpApp/FileError.cpp index 983b058..e503de0 100644 --- a/GpApp/FileError.cpp +++ b/GpApp/FileError.cpp @@ -48,6 +48,9 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName) case PLErrors::kOutOfMemory: stringIndex = 7; break; + case PLErrors::kFileIsBusy: + stringIndex = 12; + break; default: stringIndex = 1; break; diff --git a/GpApp/House.cpp b/GpApp/House.cpp index ff9d191..b265201 100644 --- a/GpApp/House.cpp +++ b/GpApp/House.cpp @@ -18,6 +18,7 @@ #include "House.h" #include "MacFileInfo.h" #include "PLStandardColors.h" +#include "PLStringCompare.h" #include "PLTimeTaggedVOSEvent.h" #include "RectUtils.h" #include "ResourceManager.h" @@ -32,6 +33,7 @@ void UpdateGoToDialog (Dialog *); int16_t GoToFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt); extern PortabilityLayer::IResourceArchive *houseResFork; +extern PortabilityLayer::CompositeFile *houseCFile; houseHand thisHouse; @@ -115,7 +117,14 @@ Boolean CreateNewHouse (void) theSpec.m_name[0] = static_cast(savePathLength); memcpy(theSpec.m_name + 1, savePath, savePathLength); - if (fm->FileExists(theSpec.m_dir, theSpec.m_name)) + // Don't try to overwrite the current house - The GPF will probably be locked anyway + if (houseCFile && theSpec.m_dir == houseCFile->GetDirectory() && !StrCmp::CompareCaseInsensitive(theSpec.m_name, houseCFile->GetFileName())) + { + CheckFileError(PLErrors::kFileIsBusy, theSpec.m_name); + return (false); + } + + if (fm->CompositeFileExists(theSpec.m_dir, theSpec.m_name)) { if (!fm->DeleteCompositeFile(theSpec.m_dir, theSpec.m_name)) { diff --git a/PortabilityLayer/PLErrorCodes.h b/PortabilityLayer/PLErrorCodes.h index 6179f8b..8205476 100644 --- a/PortabilityLayer/PLErrorCodes.h +++ b/PortabilityLayer/PLErrorCodes.h @@ -15,6 +15,7 @@ namespace PLErrors kBadFileName, kFileNotFound, kAccessDenied, + kFileIsBusy, kOutOfMemory,