mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Fix overwrite warnings not working
This commit is contained in:
@@ -179,15 +179,6 @@ Boolean SaveGame2 (void)
|
|||||||
|
|
||||||
spec.m_name[0] = static_cast<uint8_t>(savePathLength);
|
spec.m_name[0] = static_cast<uint8_t>(savePathLength);
|
||||||
memcpy(spec.m_name + 1, savePath, savePathLength);
|
memcpy(spec.m_name + 1, savePath, savePathLength);
|
||||||
|
|
||||||
if (fm->FileExists(spec.m_dir, PLPasStr(spec.m_name)))
|
|
||||||
{
|
|
||||||
if (!fm->DeleteNonCompositeFile(spec.m_dir, spec.m_name, ".dat"))
|
|
||||||
{
|
|
||||||
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thisHousePtr = *thisHouse;
|
thisHousePtr = *thisHouse;
|
||||||
|
|
||||||
|
@@ -595,7 +595,7 @@ void DoDirSearch (void)
|
|||||||
{
|
{
|
||||||
theHousesSpecs[housesFound] = MakeVFileSpec(theDirs[currentDir], f->name);
|
theHousesSpecs[housesFound] = MakeVFileSpec(theDirs[currentDir], f->name);
|
||||||
|
|
||||||
if (fm->FileExists(theDirs[currentDir], f->name))
|
if (fm->CompositeFileExists(theDirs[currentDir], f->name))
|
||||||
housesFound++;
|
housesFound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -727,15 +727,24 @@ namespace PortabilityLayer
|
|||||||
FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr);
|
FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr);
|
||||||
hit = -1;
|
hit = -1;
|
||||||
}
|
}
|
||||||
else if (PortabilityLayer::FileManager::GetInstance()->FileExists(dirID, nameStr))
|
else
|
||||||
{
|
{
|
||||||
DialogTextSubstitutions substitutions(nameStr);
|
bool fileExists = false;
|
||||||
|
if (composites)
|
||||||
|
fileExists = PortabilityLayer::FileManager::GetInstance()->CompositeFileExists(dirID, nameStr);
|
||||||
|
else
|
||||||
|
fileExists = PortabilityLayer::FileManager::GetInstance()->NonCompositeFileExists(dirID, nameStr, extension);
|
||||||
|
|
||||||
PLDrivers::GetSystemServices()->Beep();
|
if (fileExists)
|
||||||
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions);
|
{
|
||||||
|
DialogTextSubstitutions substitutions(nameStr);
|
||||||
|
|
||||||
if (subHit == kOverwriteNoButton)
|
PLDrivers::GetSystemServices()->Beep();
|
||||||
hit = -1;
|
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions);
|
||||||
|
|
||||||
|
if (subHit == kOverwriteNoButton)
|
||||||
|
hit = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,8 @@ namespace PortabilityLayer
|
|||||||
CompositeFile *OpenCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
CompositeFile *OpenCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||||
PLError_t OpenNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension, EFilePermission filePermission, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) override;
|
PLError_t OpenNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension, EFilePermission filePermission, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) override;
|
||||||
|
|
||||||
bool FileExists(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
bool CompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||||
|
bool NonCompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension) override;
|
||||||
|
|
||||||
bool DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext) override;
|
bool DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext) override;
|
||||||
bool DeleteCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
bool DeleteCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||||
@@ -65,6 +66,8 @@ namespace PortabilityLayer
|
|||||||
PLError_t OpenResources(GpIOStream *&outStream, ZipFileProxy *&outProxy, bool &outIsProxyShared) override;
|
PLError_t OpenResources(GpIOStream *&outStream, ZipFileProxy *&outProxy, bool &outIsProxyShared) override;
|
||||||
const MacFileProperties &GetProperties() const override;
|
const MacFileProperties &GetProperties() const override;
|
||||||
|
|
||||||
|
VirtualDirectory_t GetDirectory() const override;
|
||||||
|
PLPasStr GetFileName() const override;
|
||||||
bool IsDataReadOnly() const override;
|
bool IsDataReadOnly() const override;
|
||||||
|
|
||||||
void Close() override;
|
void Close() override;
|
||||||
@@ -168,15 +171,20 @@ namespace PortabilityLayer
|
|||||||
return RawOpenFileFork(dirID, filename, extension, filePermission, true, creationDisposition, outStream);
|
return RawOpenFileFork(dirID, filename, extension, filePermission, true, creationDisposition, outStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileManagerImpl::FileExists(VirtualDirectory_t dirID, const PLPasStr &filename)
|
bool FileManagerImpl::NonCompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension)
|
||||||
{
|
{
|
||||||
ExtendedFileName_t extFN;
|
ExtendedFileName_t extFN;
|
||||||
if (!FileManagerTools::ConstructFilename(extFN, filename, ".gpf"))
|
if (!FileManagerTools::ConstructFilename(extFN, filename, extension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return PLDrivers::GetFileSystem()->FileExists(dirID, extFN);
|
return PLDrivers::GetFileSystem()->FileExists(dirID, extFN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileManagerImpl::CompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||||
|
{
|
||||||
|
return NonCompositeFileExists(dirID, filename, ".gpf");
|
||||||
|
}
|
||||||
|
|
||||||
bool FileManagerImpl::DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext)
|
bool FileManagerImpl::DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext)
|
||||||
{
|
{
|
||||||
ExtendedFileName_t extFN;
|
ExtendedFileName_t extFN;
|
||||||
@@ -371,6 +379,8 @@ namespace PortabilityLayer
|
|||||||
if (fnameSize >= 64)
|
if (fnameSize >= 64)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
assert(strlen(extension) <= 4);
|
||||||
|
|
||||||
memcpy(extFN, fn.Chars(), fnameSize);
|
memcpy(extFN, fn.Chars(), fnameSize);
|
||||||
memcpy(extFN + fnameSize, extension, strlen(extension) + 1);
|
memcpy(extFN + fnameSize, extension, strlen(extension) + 1);
|
||||||
|
|
||||||
@@ -437,6 +447,16 @@ namespace PortabilityLayer
|
|||||||
return m_mfp;
|
return m_mfp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VirtualDirectory_t CompositeFileImpl::GetDirectory() const
|
||||||
|
{
|
||||||
|
return m_dirID;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLPasStr CompositeFileImpl::GetFileName() const
|
||||||
|
{
|
||||||
|
return m_filename.ToShortStr();
|
||||||
|
}
|
||||||
|
|
||||||
bool CompositeFileImpl::IsDataReadOnly() const
|
bool CompositeFileImpl::IsDataReadOnly() const
|
||||||
{
|
{
|
||||||
if (m_dataInline)
|
if (m_dataInline)
|
||||||
|
@@ -26,6 +26,8 @@ namespace PortabilityLayer
|
|||||||
virtual PLError_t OpenResources(GpIOStream *&outStream, ZipFileProxy *&outProxy, bool &outIsProxyShared) = 0;
|
virtual PLError_t OpenResources(GpIOStream *&outStream, ZipFileProxy *&outProxy, bool &outIsProxyShared) = 0;
|
||||||
virtual const MacFileProperties &GetProperties() const = 0;
|
virtual const MacFileProperties &GetProperties() const = 0;
|
||||||
|
|
||||||
|
virtual VirtualDirectory_t GetDirectory() const = 0;
|
||||||
|
virtual PLPasStr GetFileName() const = 0;
|
||||||
virtual bool IsDataReadOnly() const = 0;
|
virtual bool IsDataReadOnly() const = 0;
|
||||||
|
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
@@ -41,7 +43,8 @@ namespace PortabilityLayer
|
|||||||
virtual CompositeFile *OpenCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
virtual CompositeFile *OpenCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
||||||
virtual PLError_t OpenNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension, EFilePermission filePermission, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) = 0;
|
virtual PLError_t OpenNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension, EFilePermission filePermission, GpFileCreationDisposition_t creationDisposition, GpIOStream *&outStream) = 0;
|
||||||
|
|
||||||
virtual bool FileExists(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
virtual bool CompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
||||||
|
virtual bool NonCompositeFileExists(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension) = 0;
|
||||||
|
|
||||||
virtual bool DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext) = 0;
|
virtual bool DeleteNonCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext) = 0;
|
||||||
virtual bool DeleteCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
virtual bool DeleteCompositeFile(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
||||||
|
Reference in New Issue
Block a user