mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
File system refactoring
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "MacFileMem.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLErrorCodes.h"
|
||||
#include "ResTypeID.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -16,62 +17,89 @@ namespace PortabilityLayer
|
||||
class FileManagerImpl final : public FileManager
|
||||
{
|
||||
public:
|
||||
bool FileExists(uint32_t dirID, const PLPasStr &filename) override;
|
||||
bool FileExists(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||
bool DeleteFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||
|
||||
int OpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, short *outRefNum) override;
|
||||
int OpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, short *outRefNum) override;
|
||||
bool ReadFileProperties(uint32_t dirID, const PLPasStr &filename, MacFileProperties &properties) override;
|
||||
IOStream *GetFileStream(int fileID) override;
|
||||
PLError_t CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp) override;
|
||||
|
||||
int RawOpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream **outStream) override;
|
||||
int RawOpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream **outStream) override;
|
||||
PLError_t OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outRefNum) override;
|
||||
PLError_t OpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outRefNum) override;
|
||||
bool ReadFileProperties(VirtualDirectory_t dirID, const PLPasStr &filename, MacFileProperties &properties) override;
|
||||
|
||||
PLError_t RawOpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) override;
|
||||
PLError_t RawOpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) override;
|
||||
|
||||
static FileManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
typedef char ExtendedFileName_t[64 + 4];
|
||||
|
||||
struct OpenedFile
|
||||
{
|
||||
EVirtualDirectory m_dirID;
|
||||
PascalStr<64> m_fileName;
|
||||
|
||||
IOStream *m_stream;
|
||||
};
|
||||
|
||||
int OpenFileFork(uint32_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, short *outRefNum);
|
||||
int RawOpenFileFork(uint32_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, bool ignoreMeta, IOStream **outStream);
|
||||
PLError_t OpenFileFork(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, IOStream *&outRefNum);
|
||||
PLError_t RawOpenFileFork(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, bool ignoreMeta, bool create, IOStream *&outStream);
|
||||
|
||||
static bool ConstructFilename(ExtendedFileName_t& extFN, const PLPasStr &fn, const char *extension);
|
||||
|
||||
std::vector<OpenedFile> m_refs;
|
||||
|
||||
static FileManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
bool FileManagerImpl::FileExists(uint32_t dirID, const PLPasStr &filename)
|
||||
bool FileManagerImpl::FileExists(VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
ExtendedFileName_t extFN;
|
||||
if (!ConstructFilename(extFN, filename, ".gpf"))
|
||||
return false;
|
||||
|
||||
return HostFileSystem::GetInstance()->FileExists(static_cast<EVirtualDirectory>(dirID), extFN);
|
||||
return HostFileSystem::GetInstance()->FileExists(dirID, extFN);
|
||||
}
|
||||
|
||||
int FileManagerImpl::OpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission permission, short *outRefNum)
|
||||
bool FileManagerImpl::DeleteFile(VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
return OpenFileFork(dirID, filename, ".gpd", permission, outRefNum);
|
||||
ExtendedFileName_t extFN;
|
||||
if (!ConstructFilename(extFN, filename, ".gpf"))
|
||||
return false;
|
||||
|
||||
// PL_NotYetImplemented_TODO("FileSystem")
|
||||
return false;
|
||||
}
|
||||
|
||||
int FileManagerImpl::OpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission permission, short *outRefNum)
|
||||
PLError_t FileManagerImpl::CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp)
|
||||
{
|
||||
return OpenFileFork(dirID, filename, ".gpr", permission, outRefNum);
|
||||
MacFilePropertiesSerialized serialized;
|
||||
serialized.Serialize(mfp);
|
||||
|
||||
ExtendedFileName_t extFN;
|
||||
if (!ConstructFilename(extFN, filename, ".gpf"))
|
||||
return PLErrors::kBadFileName;
|
||||
|
||||
IOStream *stream = nullptr;
|
||||
PLError_t err = RawOpenFileFork(dirID, filename, ".gpf", EFilePermission_Write, true, true, stream);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (stream->Write(serialized.m_data, sizeof(serialized.m_data)) != sizeof(serialized.m_data))
|
||||
{
|
||||
stream->Close();
|
||||
return PLErrors::kIOError;
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
bool FileManagerImpl::ReadFileProperties(uint32_t dirID, const PLPasStr &filename, MacFileProperties &properties)
|
||||
PLError_t FileManagerImpl::OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
||||
{
|
||||
return OpenFileFork(dirID, filename, ".gpd", permission, outStream);
|
||||
}
|
||||
|
||||
PLError_t FileManagerImpl::OpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
||||
{
|
||||
return OpenFileFork(dirID, filename, ".gpr", permission, outStream);
|
||||
}
|
||||
|
||||
bool FileManagerImpl::ReadFileProperties(VirtualDirectory_t dirID, const PLPasStr &filename, MacFileProperties &properties)
|
||||
{
|
||||
IOStream *stream = nullptr;
|
||||
int err = RawOpenFileFork(dirID, filename, ".gpf", EFilePermission_Read, true, &stream);
|
||||
PLError_t err = RawOpenFileFork(dirID, filename, ".gpf", EFilePermission_Read, true, false, stream);
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
@@ -85,19 +113,14 @@ namespace PortabilityLayer
|
||||
return readOk;
|
||||
}
|
||||
|
||||
IOStream *FileManagerImpl::GetFileStream(int fileID)
|
||||
PLError_t FileManagerImpl::RawOpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
||||
{
|
||||
return m_refs[fileID].m_stream;
|
||||
return RawOpenFileFork(dirID, filename, ".gpd", permission, ignoreMeta, false, outStream);
|
||||
}
|
||||
|
||||
int FileManagerImpl::RawOpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream **outStream)
|
||||
PLError_t FileManagerImpl::RawOpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
||||
{
|
||||
return RawOpenFileFork(dirID, filename, ".gpd", permission, ignoreMeta, outStream);
|
||||
}
|
||||
|
||||
int FileManagerImpl::RawOpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream **outStream)
|
||||
{
|
||||
return RawOpenFileFork(dirID, filename, ".gpr", permission, ignoreMeta, outStream);
|
||||
return RawOpenFileFork(dirID, filename, ".gpr", permission, ignoreMeta, false, outStream);
|
||||
}
|
||||
|
||||
FileManagerImpl *FileManagerImpl::GetInstance()
|
||||
@@ -105,91 +128,72 @@ namespace PortabilityLayer
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
int FileManagerImpl::OpenFileFork(uint32_t dirID, const PLPasStr &filename, const char *extension, EFilePermission permission, short *outRefNum)
|
||||
PLError_t FileManagerImpl::OpenFileFork(VirtualDirectory_t dirID, const PLPasStr &filename, const char *extension, EFilePermission permission, IOStream *&outStream)
|
||||
{
|
||||
const size_t numRefs = m_refs.size();
|
||||
size_t refIndex = m_refs.size();
|
||||
for (size_t i = 0; i < numRefs; i++)
|
||||
{
|
||||
if (m_refs[i].m_stream == nullptr)
|
||||
{
|
||||
refIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (refIndex == 0x8000)
|
||||
return tmfoErr;
|
||||
|
||||
bool isWriteAccess = (permission == EFilePermission_Any || permission == EFilePermission_ReadWrite || permission == EFilePermission_Write);
|
||||
IOStream *stream = nullptr;
|
||||
int openError = RawOpenFileFork(dirID, filename, extension, permission, false, &stream);
|
||||
if (openError != 0)
|
||||
PLError_t openError = RawOpenFileFork(dirID, filename, extension, permission, false, isWriteAccess, stream);
|
||||
if (openError != PLErrors::kNone)
|
||||
return openError;
|
||||
|
||||
if (refIndex == numRefs)
|
||||
m_refs.push_back(OpenedFile());
|
||||
outStream = stream;
|
||||
|
||||
OpenedFile &of = m_refs[refIndex];
|
||||
of.m_stream = stream;
|
||||
of.m_dirID = static_cast<EVirtualDirectory>(dirID);
|
||||
of.m_fileName.Set(filename.Length(), filename.Chars());
|
||||
|
||||
*outRefNum = static_cast<short>(refIndex);
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
int FileManagerImpl::RawOpenFileFork(uint32_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, bool ignoreMeta, IOStream **outStream)
|
||||
PLError_t FileManagerImpl::RawOpenFileFork(VirtualDirectory_t dirID, const PLPasStr &filename, const char *ext, EFilePermission permission, bool ignoreMeta, bool create, IOStream *&outStream)
|
||||
{
|
||||
ExtendedFileName_t gpfExtFN;
|
||||
ExtendedFileName_t extFN;
|
||||
|
||||
if (filename.Length() > 63)
|
||||
return bdNamErr;
|
||||
return PLErrors::kBadFileName;
|
||||
|
||||
if (!ignoreMeta)
|
||||
{
|
||||
if (!ConstructFilename(gpfExtFN, filename, ".gpf"))
|
||||
return bdNamErr;
|
||||
return PLErrors::kBadFileName;
|
||||
|
||||
if (!HostFileSystem::GetInstance()->FileExists(static_cast<EVirtualDirectory>(dirID), gpfExtFN))
|
||||
return fnfErr;
|
||||
if (!HostFileSystem::GetInstance()->FileExists(dirID, gpfExtFN))
|
||||
return PLErrors::kFileNotFound;
|
||||
}
|
||||
|
||||
if (!ConstructFilename(extFN, filename, ext))
|
||||
return bdNamErr;
|
||||
return PLErrors::kBadFileName;
|
||||
|
||||
const bool needToCreate = !(ignoreMeta || HostFileSystem::GetInstance()->FileExists(static_cast<EVirtualDirectory>(dirID), extFN));
|
||||
const bool needToCreate = create && !HostFileSystem::GetInstance()->FileExists(dirID, extFN);
|
||||
|
||||
IOStream *fstream = nullptr;
|
||||
switch (permission)
|
||||
{
|
||||
case EFilePermission_Any:
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(static_cast<EVirtualDirectory>(dirID), extFN, true, needToCreate);
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, true, needToCreate);
|
||||
if (fstream)
|
||||
permission = EFilePermission_ReadWrite;
|
||||
else
|
||||
{
|
||||
permission = EFilePermission_Read;
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(static_cast<EVirtualDirectory>(dirID), extFN, false, needToCreate);
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, false, needToCreate);
|
||||
}
|
||||
break;
|
||||
case EFilePermission_Read:
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(static_cast<EVirtualDirectory>(dirID), extFN, false, needToCreate);
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, false, needToCreate);
|
||||
break;
|
||||
case EFilePermission_ReadWrite:
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(static_cast<EVirtualDirectory>(dirID), extFN, true, needToCreate);
|
||||
case EFilePermission_Write:
|
||||
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, true, needToCreate);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fstream)
|
||||
return permErr;
|
||||
return PLErrors::kAccessDenied;
|
||||
|
||||
*outStream = fstream;
|
||||
return noErr;
|
||||
outStream = fstream;
|
||||
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
bool FileManagerImpl::ConstructFilename(ExtendedFileName_t& extFN, const PLPasStr &fn, const char *extension)
|
||||
bool FileManagerImpl::ConstructFilename(ExtendedFileName_t &extFN, const PLPasStr &fn, const char *extension)
|
||||
{
|
||||
const size_t fnameSize = fn.Length();
|
||||
if (fnameSize >= 64)
|
||||
|
@@ -1,35 +1,40 @@
|
||||
#pragma once
|
||||
#ifndef __PL_FILE_MANAGER_H__
|
||||
#define __PL_FILE_MANAGER_H__
|
||||
|
||||
#include "FilePermission.h"
|
||||
#pragma once
|
||||
#ifndef __PL_FILE_MANAGER_H__
|
||||
#define __PL_FILE_MANAGER_H__
|
||||
|
||||
#include "FilePermission.h"
|
||||
#include "CoreDefs.h"
|
||||
#include "FilePos.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
#include "FilePos.h"
|
||||
#include "PLErrorCodes.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class IOStream;
|
||||
struct MacFileProperties;
|
||||
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
virtual bool FileExists(uint32_t dirID, const PLPasStr &filename) = 0;
|
||||
|
||||
virtual int OpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, short *outRefNum) = 0;
|
||||
virtual int OpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, short *outRefNum) = 0;
|
||||
virtual bool ReadFileProperties(uint32_t dirID, const PLPasStr &filename, MacFileProperties &properties) = 0;
|
||||
virtual IOStream *GetFileStream(int fileID) = 0;
|
||||
|
||||
virtual int RawOpenFileDF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream **outStream) = 0;
|
||||
virtual int RawOpenFileRF(uint32_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream **outStream) = 0;
|
||||
|
||||
static FileManager *GetInstance();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
class ResTypeID;
|
||||
struct MacFileProperties;
|
||||
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
virtual bool FileExists(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
||||
virtual bool DeleteFile(VirtualDirectory_t dirID, const PLPasStr &filename) = 0;
|
||||
|
||||
virtual PLError_t CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp) = 0;
|
||||
|
||||
virtual PLError_t OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outStream) = 0;
|
||||
virtual PLError_t OpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outStream) = 0;
|
||||
virtual bool ReadFileProperties(VirtualDirectory_t dirID, const PLPasStr &filename, MacFileProperties &properties) = 0;
|
||||
|
||||
virtual PLError_t RawOpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) = 0;
|
||||
virtual PLError_t RawOpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) = 0;
|
||||
|
||||
static FileManager *GetInstance();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -9,6 +9,7 @@ namespace PortabilityLayer
|
||||
EFilePermission_Any,
|
||||
EFilePermission_Read,
|
||||
EFilePermission_ReadWrite,
|
||||
EFilePermission_Write,
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
void FontFamily::AddFont(int flags, const char *path, FontHacks fontHacks)
|
||||
{
|
||||
PortabilityLayer::IOStream *sysFontStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::EVirtualDirectory_Fonts, path, false, false);
|
||||
PortabilityLayer::IOStream *sysFontStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFonts, path, false, false);
|
||||
if (!sysFontStream)
|
||||
return;
|
||||
|
||||
|
@@ -12,9 +12,9 @@ namespace PortabilityLayer
|
||||
class HostFileSystem
|
||||
{
|
||||
public:
|
||||
virtual bool FileExists(EVirtualDirectory virtualDirectory, const char *path) = 0;
|
||||
virtual IOStream *OpenFile(EVirtualDirectory virtualDirectory, const char *path, bool writeAccess, bool create) = 0;
|
||||
virtual HostDirectoryCursor *ScanDirectory(EVirtualDirectory virtualDirectory) = 0;
|
||||
virtual bool FileExists(VirtualDirectory_t virtualDirectory, const char *path) = 0;
|
||||
virtual IOStream *OpenFile(VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, bool create) = 0;
|
||||
virtual HostDirectoryCursor *ScanDirectory(VirtualDirectory_t virtualDirectory) = 0;
|
||||
|
||||
static HostFileSystem *GetInstance();
|
||||
static void SetInstance(HostFileSystem *instance);
|
||||
|
@@ -30,7 +30,7 @@ namespace PortabilityLayer
|
||||
uint32_t m_creationDate;
|
||||
uint32_t m_modifiedDate;
|
||||
|
||||
void Serialize(void *buffer);
|
||||
void Serialize(void *buffer) const;
|
||||
void Deserialize(const void *buffer);
|
||||
};
|
||||
|
||||
|
@@ -551,9 +551,7 @@ namespace PortabilityLayer
|
||||
|
||||
if (m_menuBarGraf == nullptr)
|
||||
{
|
||||
int depth = PortabilityLayer::QDManager::GetInstance()->DepthForPixelFormat(pixelFormat);
|
||||
|
||||
if (qdManager->NewGWorld(&m_menuBarGraf, depth, menuRect, nullptr, 0) != 0)
|
||||
if (qdManager->NewGWorld(&m_menuBarGraf, pixelFormat, menuRect, nullptr) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1015,7 @@ namespace PortabilityLayer
|
||||
GpPixelFormat_t pixelFormat;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &pixelFormat);
|
||||
|
||||
if (qdManager->NewGWorld(&m_menuGraf, qdManager->DepthForPixelFormat(pixelFormat), menuRect, nullptr, 0) != 0)
|
||||
if (qdManager->NewGWorld(&m_menuGraf, pixelFormat, menuRect, nullptr) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#include "PLAliases.h"
|
||||
|
||||
OSErr ResolveAliasFile(FSSpecPtr fsSpec, Boolean recursive, Boolean *outIsFolder, Boolean *outWasAliased)
|
||||
{
|
||||
*outIsFolder = PL_FALSE;
|
||||
*outWasAliased = PL_FALSE;
|
||||
return noErr;
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef __PL_ALIASES_H__
|
||||
#define __PL_ALIASES_H__
|
||||
|
||||
#include "PLCore.h"
|
||||
|
||||
OSErr ResolveAliasFile(FSSpecPtr fsSpec, Boolean recursive, Boolean *outIsFolder, Boolean *outWasAliased);
|
||||
|
||||
#endif
|
@@ -1,46 +1,46 @@
|
||||
#include "PLAppleEvents.h"
|
||||
#include "AEManager.h"
|
||||
|
||||
OSErr AEGetParamDesc(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, AEDescList *descList)
|
||||
PLError_t AEGetParamDesc(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, AEDescList *descList)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AEDisposeDesc(AEDescList *descList)
|
||||
PLError_t AEDisposeDesc(AEDescList *descList)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AECountItems(AEDescList *descList, long *count)
|
||||
PLError_t AECountItems(AEDescList *descList, long *count)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AEGetNthPtr(AEDescList *descList, long index, DescType desiredType, AEKeyword *keyword, DescType *type, void *data, Size maxSize, Size *actualSize)
|
||||
PLError_t AEGetNthPtr(AEDescList *descList, long index, DescType desiredType, AEKeyword *keyword, DescType *type, void *data, Size maxSize, Size *actualSize)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AEGetAttributePtr(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, DescType *type, void *data, Size maxSize, Size *actualSize)
|
||||
PLError_t AEGetAttributePtr(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, DescType *type, void *data, Size maxSize, Size *actualSize)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AEInstallEventHandler(AEEventClass eventClass, AEEventID eventID, AEEventHandlerUPP handler, UInt32 ref, bool isSysHandler)
|
||||
PLError_t AEInstallEventHandler(AEEventClass eventClass, AEEventID eventID, AEEventHandlerUPP handler, UInt32 ref, bool isSysHandler)
|
||||
{
|
||||
PortabilityLayer::AEManager::GetInstance()->InstallEventHandler(eventClass, eventID, handler, ref, isSysHandler);
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AESetInteractionAllowed(AEInteractAllowed level)
|
||||
PLError_t AESetInteractionAllowed(AEInteractAllowed level)
|
||||
{
|
||||
PortabilityLayer::AEManager::GetInstance()->SetInteractAllowed(level);
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
AEEventHandlerUPP NewAEEventHandlerProc(AEEventHandler handler)
|
||||
|
@@ -19,13 +19,13 @@ struct AEDesc
|
||||
|
||||
typedef AEEventHandler AEEventHandlerUPP;
|
||||
|
||||
OSErr AEGetParamDesc(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, AEDescList *descList);
|
||||
OSErr AEDisposeDesc(AEDescList *descList);
|
||||
OSErr AECountItems(AEDescList *descList, long *count);
|
||||
OSErr AEGetNthPtr(AEDescList *descList, long index, DescType desiredType, AEKeyword *keyword, DescType *type, void *data, Size maxSize, Size *actualSize);
|
||||
OSErr AEGetAttributePtr(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, DescType *type, void *data, Size maxSize, Size *actualSize);
|
||||
OSErr AEInstallEventHandler(AEEventClass eventClass, AEEventID eventID, AEEventHandlerUPP handler, UInt32 ref, bool isSysHandler);
|
||||
OSErr AESetInteractionAllowed(AEInteractAllowed level);
|
||||
PLError_t AEGetParamDesc(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, AEDescList *descList);
|
||||
PLError_t AEDisposeDesc(AEDescList *descList);
|
||||
PLError_t AECountItems(AEDescList *descList, long *count);
|
||||
PLError_t AEGetNthPtr(AEDescList *descList, long index, DescType desiredType, AEKeyword *keyword, DescType *type, void *data, Size maxSize, Size *actualSize);
|
||||
PLError_t AEGetAttributePtr(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, DescType *type, void *data, Size maxSize, Size *actualSize);
|
||||
PLError_t AEInstallEventHandler(AEEventClass eventClass, AEEventID eventID, AEEventHandlerUPP handler, UInt32 ref, bool isSysHandler);
|
||||
PLError_t AESetInteractionAllowed(AEInteractAllowed level);
|
||||
|
||||
AEEventHandlerUPP NewAEEventHandlerProc(AEEventHandler handler);
|
||||
|
||||
|
@@ -2,6 +2,8 @@
|
||||
#ifndef __PL_APPLE_EVENTS_COMMON_TYPES_H__
|
||||
#define __PL_APPLE_EVENTS_COMMON_TYPES_H__
|
||||
|
||||
#include "PLErrorCodes.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct AppleEvent;
|
||||
@@ -45,6 +47,6 @@ enum AEInteractAllowed
|
||||
kAEInteractWithAll
|
||||
};
|
||||
|
||||
typedef int(*AEEventHandler)(const AppleEvent *theAE, AppleEvent *reply, uint32_t ref);
|
||||
typedef PLError_t (*AEEventHandler)(const AppleEvent *theAE, AppleEvent *reply, uint32_t ref);
|
||||
|
||||
#endif
|
||||
|
@@ -202,12 +202,6 @@ Rect BERect::ToRect() const
|
||||
return rect;
|
||||
}
|
||||
|
||||
OSErr FSClose(short fsRef)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
}
|
||||
|
||||
CursHandle GetCursor(int cursorID)
|
||||
{
|
||||
return reinterpret_cast<CursHandle>(GetResource('CURS', cursorID));
|
||||
@@ -465,7 +459,7 @@ long MenuSelect(Point point)
|
||||
long MenuKey(int charCode)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
long TickCount()
|
||||
@@ -605,23 +599,10 @@ UInt32 FreeMem()
|
||||
return 256 * 1024 * 1024;
|
||||
}
|
||||
|
||||
OSErr AEProcessAppleEvent(EventRecord *evt)
|
||||
PLError_t AEProcessAppleEvent(EventRecord *evt)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr FindFolder(int refNum, int posType, bool createFolder, short *volumeRef, long *dirID)
|
||||
{
|
||||
switch (posType)
|
||||
{
|
||||
case kPreferencesFolderType:
|
||||
*volumeRef = 0;
|
||||
*dirID = PortabilityLayer::EVirtualDirectory_Prefs;
|
||||
return noErr;
|
||||
default:
|
||||
return genericErr;
|
||||
}
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
||||
@@ -649,41 +630,46 @@ void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
||||
}
|
||||
}
|
||||
|
||||
OSErr PBDirCreate(HFileParam *fileParam, bool asynchronous)
|
||||
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr FSMakeFSSpec(int refNum, long dirID, const PLPasStr &fileName, FSSpec *spec)
|
||||
|
||||
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName)
|
||||
{
|
||||
VFileSpec spec;
|
||||
|
||||
if (fileName.Length() >= sizeof(spec->name))
|
||||
return genericErr;
|
||||
assert(fileName.Length() < sizeof(spec.m_name));
|
||||
|
||||
PortabilityLayer::Utils::MakePStr(spec->name, fileName.Length(), fileName.Chars());
|
||||
spec->vRefNum = refNum;
|
||||
spec->parID = dirID;
|
||||
spec.m_dir = dir;
|
||||
spec.m_name[0] = static_cast<uint8_t>(fileName.Length());
|
||||
memcpy(spec.m_name + 1, fileName.UChars(), fileName.Length());
|
||||
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(dirID, fileName))
|
||||
return fnfErr;
|
||||
|
||||
return noErr;
|
||||
return spec;
|
||||
}
|
||||
|
||||
OSErr FSpCreate(const FSSpec *spec, UInt32 creator, UInt32 fileType, ScriptCode scriptTag)
|
||||
PLError_t FSpCreate(const VFileSpec &spec, UInt32 creator, UInt32 fileType)
|
||||
{
|
||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||
|
||||
PortabilityLayer::MacFileProperties props;
|
||||
PortabilityLayer::ResTypeIDCodec::Encode(creator, props.m_fileCreator);
|
||||
PortabilityLayer::ResTypeIDCodec::Encode(fileType, props.m_fileType);
|
||||
|
||||
PL_NotYetImplemented_TODO("DateTime");
|
||||
|
||||
return fm->CreateFile(spec.m_dir, spec.m_name, props);
|
||||
}
|
||||
|
||||
PLError_t FSpDirCreate(const VFileSpec &spec, long *outDirID)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr FSpDirCreate(const FSSpec *spec, ScriptCode script, long *outDirID)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr FSpOpenDF(const FSSpec *spec, int permission, short *refNum)
|
||||
PLError_t FSpOpenDF(const VFileSpec &spec, int permission, PortabilityLayer::IOStream *&stream)
|
||||
{
|
||||
PortabilityLayer::EFilePermission perm = PortabilityLayer::EFilePermission_Any;
|
||||
switch (permission)
|
||||
@@ -699,85 +685,47 @@ OSErr FSpOpenDF(const FSSpec *spec, int permission, short *refNum)
|
||||
perm = PortabilityLayer::EFilePermission_Any;
|
||||
break;
|
||||
default:
|
||||
return permErr;
|
||||
return PLErrors::kAccessDenied;
|
||||
}
|
||||
|
||||
return PortabilityLayer::FileManager::GetInstance()->OpenFileDF(spec->parID, spec->name, perm, refNum);
|
||||
return PortabilityLayer::FileManager::GetInstance()->OpenFileDF(spec.m_dir, spec.m_name, perm, stream);
|
||||
}
|
||||
|
||||
OSErr FSWrite(short refNum, long *byteCount, const void *data)
|
||||
PLError_t FSpDelete(const VFileSpec &spec)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr FSRead(short refNum, long *byteCount, void *data)
|
||||
{
|
||||
PortabilityLayer::IOStream *stream = PortabilityLayer::FileManager::GetInstance()->GetFileStream(refNum);
|
||||
|
||||
const size_t bytesRead = stream->Read(data, static_cast<size_t>(*byteCount));
|
||||
*byteCount = static_cast<long>(bytesRead);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr FSpDelete(const FSSpec *spec)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr FSpGetFInfo(const FSSpec *spec, FInfo *finfo)
|
||||
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfo)
|
||||
{
|
||||
PortabilityLayer::MacFileProperties mfp;
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->ReadFileProperties(static_cast<uint32_t>(spec->parID), spec->name, mfp))
|
||||
return fnfErr;
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->ReadFileProperties(spec.m_dir, spec.m_name, mfp))
|
||||
return PLErrors::kFileNotFound;
|
||||
|
||||
finfo->fdType = PortabilityLayer::ResTypeIDCodec::Decode(mfp.m_fileType);
|
||||
finfo.m_type = PortabilityLayer::ResTypeID(mfp.m_fileType);
|
||||
finfo.m_creator = PortabilityLayer::ResTypeID(mfp.m_fileCreator);
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SetFPos(short refNum, SetFPosWhere where, long offset)
|
||||
{
|
||||
switch (where)
|
||||
{
|
||||
case fsFromStart:
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->GetFileStream(refNum)->SeekStart(static_cast<PortabilityLayer::UFilePos_t>(offset)))
|
||||
return ioErr;
|
||||
break;
|
||||
default:
|
||||
return genericErr;
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr GetEOF(short refNum, long *byteCount)
|
||||
{
|
||||
const PortabilityLayer::UFilePos_t fileSize = PortabilityLayer::FileManager::GetInstance()->GetFileStream(refNum)->Size();
|
||||
|
||||
*byteCount = static_cast<long>(fileSize);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr SetEOF(short refNum, long byteCount)
|
||||
PLError_t SetEOF(short refNum, long byteCount)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async)
|
||||
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
DirectoryFileListEntry *GetDirectoryFiles(long dirID)
|
||||
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID)
|
||||
{
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
PortabilityLayer::HostFileSystem *fs = PortabilityLayer::HostFileSystem::GetInstance();
|
||||
PortabilityLayer::HostDirectoryCursor *dirCursor = fs->ScanDirectory(static_cast<PortabilityLayer::EVirtualDirectory>(dirID));
|
||||
PortabilityLayer::HostDirectoryCursor *dirCursor = fs->ScanDirectory(dirID);
|
||||
|
||||
DirectoryFileListEntry *firstDFL = nullptr;
|
||||
DirectoryFileListEntry *lastDFL = nullptr;
|
||||
@@ -798,7 +746,7 @@ DirectoryFileListEntry *GetDirectoryFiles(long dirID)
|
||||
if (!strcmp(&filename[fnLen - 4], ".gpf"))
|
||||
{
|
||||
const size_t dotPos = fnLen - 4;
|
||||
PortabilityLayer::IOStream *stream = fs->OpenFile(static_cast<PortabilityLayer::EVirtualDirectory>(dirID), filename, false, false);
|
||||
PortabilityLayer::IOStream *stream = fs->OpenFile(dirID, filename, false, false);
|
||||
if (!stream)
|
||||
continue;
|
||||
|
||||
@@ -1020,19 +968,19 @@ long GetHandleSize(Handle handle)
|
||||
return static_cast<long>(block->m_size);
|
||||
}
|
||||
|
||||
OSErr PtrAndHand(const void *data, Handle handle, Size size)
|
||||
PLError_t PtrAndHand(const void *data, Handle handle, Size size)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SetHandleSize(Handle hdl, Size newSize)
|
||||
PLError_t SetHandleSize(Handle hdl, Size newSize)
|
||||
{
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
if (!mm->ResizeHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(hdl), newSize))
|
||||
return genericErr;
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
void *NewPtr(Size size)
|
||||
@@ -1068,12 +1016,6 @@ char HGetState(Handle handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSErr MemError()
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BlockMove(const void *src, void *dest, Size size)
|
||||
{
|
||||
memcpy(dest, src, size);
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include "SharedTypes.h"
|
||||
#include "QDPort.h"
|
||||
#include "QDGraf.h"
|
||||
#include "ResTypeID.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(error:4311) // Pointer truncation to int
|
||||
@@ -17,6 +19,7 @@ struct IGpColorCursor;
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct MMHandleBlock;
|
||||
class IOStream;
|
||||
}
|
||||
|
||||
typedef uint8_t Boolean;
|
||||
@@ -25,7 +28,6 @@ typedef uint8_t UInt8;
|
||||
typedef int16_t SInt16;
|
||||
typedef int32_t Int32;
|
||||
typedef uint32_t UInt32;
|
||||
typedef int OSErr;
|
||||
|
||||
typedef size_t Size;
|
||||
|
||||
@@ -132,17 +134,17 @@ struct ColorSpec
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct FSSpec
|
||||
struct VFileSpec
|
||||
{
|
||||
Str63 name;
|
||||
UInt32 parID; // Directory ID
|
||||
SInt16 vRefNum; // Volume ID
|
||||
PortabilityLayer::VirtualDirectory_t m_dir;
|
||||
Str63 m_name;
|
||||
};
|
||||
|
||||
typedef struct FInfo
|
||||
struct VFileInfo
|
||||
{
|
||||
UInt32 fdType;
|
||||
} FInfo;
|
||||
PortabilityLayer::ResTypeID m_type;
|
||||
PortabilityLayer::ResTypeID m_creator;
|
||||
};
|
||||
|
||||
struct HFileParam
|
||||
{
|
||||
@@ -166,7 +168,6 @@ typedef CGrafPtr GWorldPtr;
|
||||
typedef Window *WindowPtr;
|
||||
typedef Cursor *CursPtr;
|
||||
typedef CCursor *CCrsrPtr;
|
||||
typedef FSSpec *FSSpecPtr;
|
||||
typedef Menu *MenuPtr;
|
||||
typedef CInfoPBRec *CInfoPBPtr;
|
||||
typedef VersionRecord *VersRecPtr;
|
||||
@@ -210,26 +211,6 @@ enum EventCode
|
||||
kHighLevelEvent,
|
||||
};
|
||||
|
||||
enum ScriptCode
|
||||
{
|
||||
smSystemScript,
|
||||
};
|
||||
|
||||
enum FindFolderRefNum
|
||||
{
|
||||
kOnSystemDisk,
|
||||
};
|
||||
|
||||
enum FindFolderType
|
||||
{
|
||||
kPreferencesFolderType,
|
||||
};
|
||||
|
||||
enum SetFPosWhere
|
||||
{
|
||||
fsFromStart,
|
||||
};
|
||||
|
||||
enum BuiltinWDEFs
|
||||
{
|
||||
noGrowDocProc = 4, // Movable, not resizable
|
||||
@@ -261,8 +242,6 @@ static const int nullEvent = 0;
|
||||
|
||||
//void FlushEvents(int eventMask, int stopMask);
|
||||
|
||||
OSErr FSClose(short fsRef);
|
||||
|
||||
void InitCursor();
|
||||
CursHandle GetCursor(int cursorID);
|
||||
CCrsrHandle GetCCursor(int cursorID);
|
||||
@@ -319,28 +298,24 @@ void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, cons
|
||||
|
||||
UInt32 FreeMem();
|
||||
|
||||
OSErr AEProcessAppleEvent(EventRecord *evt);
|
||||
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
||||
|
||||
OSErr FindFolder(int refNum, int posType, bool createFolder, short *volumeRef, long *dirID);
|
||||
PLError_t FindFolder(int refNum, int posType, bool createFolder, short *volumeRef, long *dirID);
|
||||
void GetIndString(unsigned char *str, int stringsID, int fnameIndex); // Fetches a string resource of some sort
|
||||
OSErr PBDirCreate(HFileParam *fileParam, bool asynchronous);
|
||||
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous);
|
||||
|
||||
OSErr FSMakeFSSpec(int refNum, long dirID, const PLPasStr &fileName, FSSpec *spec);
|
||||
OSErr FSpCreate(const FSSpec *spec, UInt32 creator, UInt32 fileType, ScriptCode scriptTag);
|
||||
OSErr FSpDirCreate(const FSSpec *spec, ScriptCode script, long *outDirID);
|
||||
OSErr FSpOpenDF(const FSSpec *spec, int permission, short *refNum);
|
||||
OSErr FSpOpenRF(const FSSpec *spec, int permission, short *refNum);
|
||||
OSErr FSWrite(short refNum, long *byteCount, const void *data);
|
||||
OSErr FSRead(short refNum, long *byteCount, void *data);
|
||||
OSErr FSpDelete(const FSSpec *spec);
|
||||
OSErr FSpGetFInfo(const FSSpec *spec, FInfo *finfo);
|
||||
OSErr SetFPos(short refNum, SetFPosWhere where, long offset);
|
||||
OSErr GetEOF(short refNum, long *byteCount);
|
||||
OSErr SetEOF(short refNum, long byteCount);
|
||||
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName);
|
||||
|
||||
OSErr PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async);
|
||||
PLError_t FSpCreate(const VFileSpec &spec, UInt32 creator, UInt32 fileType);
|
||||
PLError_t FSpDirCreate(const VFileSpec &spec, long *outDirID);
|
||||
PLError_t FSpOpenDF(const VFileSpec &spec, int permission, PortabilityLayer::IOStream *&stream);
|
||||
PLError_t FSpOpenRF(const VFileSpec &spec, int permission, PortabilityLayer::IOStream *&stream);
|
||||
PLError_t FSpDelete(const VFileSpec &spec);
|
||||
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfoOut);
|
||||
|
||||
DirectoryFileListEntry *GetDirectoryFiles(long dirID);
|
||||
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async);
|
||||
|
||||
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID);
|
||||
void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL);
|
||||
|
||||
short StringWidth(const PLPasStr &str);
|
||||
@@ -366,8 +341,8 @@ Handle NewHandle(Size size);
|
||||
void DisposeHandle(Handle handle);
|
||||
long GetHandleSize(Handle handle);
|
||||
|
||||
OSErr PtrAndHand(const void *data, Handle handle, Size size); // Appends data to the end of a handle
|
||||
OSErr SetHandleSize(Handle hdl, Size newSize);
|
||||
PLError_t PtrAndHand(const void *data, Handle handle, Size size); // Appends data to the end of a handle
|
||||
PLError_t SetHandleSize(Handle hdl, Size newSize);
|
||||
|
||||
void *NewPtr(Size size);
|
||||
void *NewPtrClear(Size size);
|
||||
@@ -376,7 +351,7 @@ void DisposePtr(void *ptr);
|
||||
Size MaxMem(Size *growBytes);
|
||||
void PurgeSpace(long *totalFree, long *contiguousFree);
|
||||
|
||||
OSErr MemError();
|
||||
PLError_t MemError();
|
||||
|
||||
void BlockMove(const void *src, void *dest, Size size);
|
||||
|
||||
|
@@ -2,32 +2,30 @@
|
||||
#ifndef __PL_ERROR_CODES_H__
|
||||
#define __PL_ERROR_CODES_H__
|
||||
|
||||
enum ErrorCodes
|
||||
|
||||
namespace PLErrors
|
||||
{
|
||||
noErr,
|
||||
enum PLError
|
||||
{
|
||||
kNone = 0,
|
||||
|
||||
fnfErr,
|
||||
eofErr,
|
||||
userCanceledErr,
|
||||
dirFulErr,
|
||||
dskFulErr,
|
||||
ioErr,
|
||||
bdNamErr,
|
||||
fnOpnErr,
|
||||
mFulErr,
|
||||
tmfoErr,
|
||||
wPrErr,
|
||||
fLckdErr,
|
||||
vLckdErr,
|
||||
fBsyErr,
|
||||
dupFNErr,
|
||||
opWrErr,
|
||||
volOffLinErr,
|
||||
permErr,
|
||||
wrPermErr,
|
||||
queueFull,
|
||||
kInvalidParameter,
|
||||
|
||||
genericErr,
|
||||
};
|
||||
kFileHandlesExhausted,
|
||||
kBadFileName,
|
||||
kFileNotFound,
|
||||
kAccessDenied,
|
||||
|
||||
kOutOfMemory,
|
||||
|
||||
kAudioError,
|
||||
|
||||
kIOError,
|
||||
|
||||
kUserCancelled_TEMP,
|
||||
};
|
||||
}
|
||||
|
||||
typedef PLErrors::PLError PLError_t;
|
||||
|
||||
#endif
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "PLMovies.h"
|
||||
|
||||
OSErr EnterMovies()
|
||||
PLError_t EnterMovies()
|
||||
{
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
UserData GetMovieUserData(Movie movie)
|
||||
@@ -17,46 +17,46 @@ int CountUserDataType(UserData userData, UInt32 type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSErr RemoveUserData(UserData userData, UInt32 type, int index)
|
||||
PLError_t RemoveUserData(UserData userData, UInt32 type, int index)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr AddUserData(UserData userData, Handle data, UInt32 type)
|
||||
PLError_t AddUserData(UserData userData, Handle data, UInt32 type)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr OpenMovieFile(const FSSpec *fsSpec, short *outRefNum, int permissions)
|
||||
PLError_t OpenMovieFile(const VFileSpec &fsSpec, short *outRefNum, int permissions)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Movies");
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr NewMovieFromFile(Movie *movie, short refNum, const short *optResId, StringPtr resName, int flags, Boolean *unused)
|
||||
PLError_t NewMovieFromFile(Movie *movie, short refNum, const short *optResId, StringPtr resName, int flags, Boolean *unused)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Movies");
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr CloseMovieFile(short refNum)
|
||||
PLError_t CloseMovieFile(short refNum)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr GoToBeginningOfMovie(Movie movie)
|
||||
PLError_t GoToBeginningOfMovie(Movie movie)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr LoadMovieIntoRam(Movie movie, TimeValue time, TimeValue duration, int flags)
|
||||
PLError_t LoadMovieIntoRam(Movie movie, TimeValue time, TimeValue duration, int flags)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
TimeValue GetMovieTime(Movie movie, TimeRecord *outCurrentTime)
|
||||
@@ -71,10 +71,10 @@ TimeValue GetMovieDuration(Movie movie)
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSErr PrerollMovie(Movie movie, TimeValue time, UInt32 rate)
|
||||
PLError_t PrerollMovie(Movie movie, TimeValue time, UInt32 rate)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
TimeBase GetMovieTimeBase(Movie movie)
|
||||
@@ -83,10 +83,10 @@ TimeBase GetMovieTimeBase(Movie movie)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OSErr SetTimeBaseFlags(TimeBase timeBase, int flags)
|
||||
PLError_t SetTimeBaseFlags(TimeBase timeBase, int flags)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
void SetMovieMasterTimeBase(Movie movie, TimeBase timeBase, void *unused)
|
||||
|
@@ -34,22 +34,22 @@ typedef TimeBaseObject *TimeBase;
|
||||
typedef MovieObject *Movie;
|
||||
|
||||
|
||||
OSErr EnterMovies();
|
||||
PLError_t EnterMovies();
|
||||
|
||||
UserData GetMovieUserData(Movie movie);
|
||||
int CountUserDataType(UserData userData, UInt32 type);
|
||||
OSErr RemoveUserData(UserData userData, UInt32 type, int index); // Index is 1-based
|
||||
OSErr AddUserData(UserData userData, Handle data, UInt32 type);
|
||||
OSErr OpenMovieFile(const FSSpec *fsSpec, short *outRefNum, int permissions);
|
||||
OSErr NewMovieFromFile(Movie *movie, short refNum, const short *optResId, StringPtr resName, int flags, Boolean *unused);
|
||||
OSErr CloseMovieFile(short refNum);
|
||||
OSErr GoToBeginningOfMovie(Movie movie);
|
||||
OSErr LoadMovieIntoRam(Movie movie, TimeValue time, TimeValue duration, int flags);
|
||||
PLError_t RemoveUserData(UserData userData, UInt32 type, int index); // Index is 1-based
|
||||
PLError_t AddUserData(UserData userData, Handle data, UInt32 type);
|
||||
PLError_t OpenMovieFile(const VFileSpec &fsSpec, short *outRefNum, int permissions);
|
||||
PLError_t NewMovieFromFile(Movie *movie, short refNum, const short *optResId, StringPtr resName, int flags, Boolean *unused);
|
||||
PLError_t CloseMovieFile(short refNum);
|
||||
PLError_t GoToBeginningOfMovie(Movie movie);
|
||||
PLError_t LoadMovieIntoRam(Movie movie, TimeValue time, TimeValue duration, int flags);
|
||||
TimeValue GetMovieTime(Movie movie, TimeRecord *outCurrentTime);
|
||||
TimeValue GetMovieDuration(Movie movie);
|
||||
OSErr PrerollMovie(Movie movie, TimeValue time, UInt32 rate);
|
||||
PLError_t PrerollMovie(Movie movie, TimeValue time, UInt32 rate);
|
||||
TimeBase GetMovieTimeBase(Movie movie);
|
||||
OSErr SetTimeBaseFlags(TimeBase timeBase, int flags);
|
||||
PLError_t SetTimeBaseFlags(TimeBase timeBase, int flags);
|
||||
void SetMovieMasterTimeBase(Movie movie, TimeBase timeBase, void *unused);
|
||||
void GetMovieBox(Movie movie, Rect *rect);
|
||||
void StopMovie(Movie movie);
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#include "PLNavigation.h"
|
||||
|
||||
OSErr NavGetDefaultDialogOptions(NavDialogOptions *options)
|
||||
PLError_t NavGetDefaultDialogOptions(NavDialogOptions *options)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr NavPutFile(AEDesc *defaultLocation, NavReplyRecord *reply, NavDialogOptions *dlgOptions, void *unknown, UInt32 fileType, UInt32 fileCreator, void *unknown2)
|
||||
PLError_t NavPutFile(AEDesc *defaultLocation, NavReplyRecord *reply, NavDialogOptions *dlgOptions, void *unknown, UInt32 fileType, UInt32 fileCreator, void *unknown2)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
@@ -14,14 +14,13 @@ struct NavReplyRecord
|
||||
int vRefNum;
|
||||
long parID; // Directory?
|
||||
AEDescList selection;
|
||||
ScriptCode keyScript; // ???
|
||||
};
|
||||
|
||||
struct NavDialogOptions
|
||||
{
|
||||
};
|
||||
|
||||
OSErr NavGetDefaultDialogOptions(NavDialogOptions *options);
|
||||
OSErr NavPutFile(AEDesc *defaultLocation, NavReplyRecord *reply, NavDialogOptions *dlgOptions, void *unknown, UInt32 fileType, UInt32 fileCreator, void *unknown2);
|
||||
PLError_t NavGetDefaultDialogOptions(NavDialogOptions *options);
|
||||
PLError_t NavPutFile(AEDesc *defaultLocation, NavReplyRecord *reply, NavDialogOptions *dlgOptions, void *unknown, UInt32 fileType, UInt32 fileCreator, void *unknown2);
|
||||
|
||||
#endif
|
||||
|
@@ -232,9 +232,9 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, int flags)
|
||||
PLError_t NewGWorld(GWorldPtr *gworld, GpPixelFormat_t pixelFormat, const Rect *bounds, CTabHandle colorTable)
|
||||
{
|
||||
return PortabilityLayer::QDManager::GetInstance()->NewGWorld(gworld, depth, *bounds, colorTable, flags);
|
||||
return PortabilityLayer::QDManager::GetInstance()->NewGWorld(gworld, pixelFormat, *bounds, colorTable);
|
||||
}
|
||||
|
||||
void DisposeGWorld(GWorldPtr gworld)
|
||||
@@ -250,11 +250,6 @@ PixMapHandle GetGWorldPixMap(GWorldPtr gworld)
|
||||
return gworld->m_port.GetPixMap();
|
||||
}
|
||||
|
||||
void LockPixels(PixMapHandle pixmap)
|
||||
{
|
||||
(void)pixmap;
|
||||
}
|
||||
|
||||
PicHandle GetPicture(short resID)
|
||||
{
|
||||
return reinterpret_cast<PicHandle>(PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', resID));
|
||||
|
@@ -25,11 +25,10 @@ enum QDFlags
|
||||
useTempMem = 1,
|
||||
};
|
||||
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, int flags);
|
||||
PLError_t NewGWorld(GWorldPtr *gworld, GpPixelFormat_t pixelFormat, const Rect *bounds, CTabHandle colorTable);
|
||||
void DisposeGWorld(GWorldPtr gworld);
|
||||
|
||||
PixMapHandle GetGWorldPixMap(GWorldPtr gworld);
|
||||
void LockPixels(PixMapHandle pixmap);
|
||||
|
||||
PicHandle GetPicture(short resID);
|
||||
|
||||
|
@@ -57,16 +57,16 @@ void EndUpdate(WindowPtr graf)
|
||||
graf->m_graf.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
OSErr GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags)
|
||||
PLError_t GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr PlotIconSuite(Rect *rect, IconAlignmentType alignType, IconTransformType transformType, Handle iconSuite)
|
||||
PLError_t PlotIconSuite(Rect *rect, IconAlignmentType alignType, IconTransformType transformType, Handle iconSuite)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
CIconHandle GetCIcon(short resID)
|
||||
@@ -75,10 +75,10 @@ CIconHandle GetCIcon(short resID)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OSErr PlotCIcon(Rect *rect, CIconHandle icon)
|
||||
PLError_t PlotCIcon(Rect *rect, CIconHandle icon)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
void DisposeCIcon(CIconHandle icon)
|
||||
|
@@ -102,11 +102,11 @@ void SetPortDialogPort(Dialog *dialog);
|
||||
void BeginUpdate(WindowPtr graf);
|
||||
void EndUpdate(WindowPtr graf);
|
||||
|
||||
OSErr GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags);
|
||||
OSErr PlotIconSuite(Rect *rect, IconAlignmentType alignType, IconTransformType transformType, Handle iconSuite);
|
||||
PLError_t GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags);
|
||||
PLError_t PlotIconSuite(Rect *rect, IconAlignmentType alignType, IconTransformType transformType, Handle iconSuite);
|
||||
|
||||
CIconHandle GetCIcon(short resID);
|
||||
OSErr PlotCIcon(Rect *rect, CIconHandle icon);
|
||||
PLError_t PlotCIcon(Rect *rect, CIconHandle icon);
|
||||
void DisposeCIcon(CIconHandle icon);
|
||||
|
||||
void SetRect(Rect *rect, short left, short top, short right, short bottom);
|
||||
|
@@ -25,7 +25,7 @@ namespace PortabilityLayer
|
||||
|
||||
void SetResLoad(bool load) override;
|
||||
|
||||
short OpenResFork(EVirtualDirectory virtualDir, const PLPasStr &filename) override;
|
||||
short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
||||
MMHandleBlock *GetResource(const ResTypeID &resType, int id) override;
|
||||
|
||||
short GetCurrentResFile() const override;
|
||||
@@ -60,7 +60,7 @@ namespace PortabilityLayer
|
||||
|
||||
void ResourceManagerImpl::Init()
|
||||
{
|
||||
m_currentResFile = OpenResFork(EVirtualDirectory_ApplicationData, PSTR("ApplicationResources"));
|
||||
m_currentResFile = OpenResFork(VirtualDirectories::kApplicationData, PSTR("ApplicationResources"));
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::Shutdown()
|
||||
@@ -91,7 +91,7 @@ namespace PortabilityLayer
|
||||
m_load = load;
|
||||
}
|
||||
|
||||
short ResourceManagerImpl::OpenResFork(EVirtualDirectory virtualDir, const PLPasStr &filename)
|
||||
short ResourceManagerImpl::OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
||||
{
|
||||
const size_t numSlots = m_resFiles.size();
|
||||
size_t resFileIndex = numSlots;
|
||||
@@ -109,7 +109,7 @@ namespace PortabilityLayer
|
||||
return -1;
|
||||
|
||||
IOStream *fStream = nullptr;
|
||||
if (FileManager::GetInstance()->RawOpenFileRF(virtualDir, filename, EFilePermission_Read, true, &fStream) != noErr)
|
||||
if (FileManager::GetInstance()->RawOpenFileRF(virtualDir, filename, EFilePermission_Read, true, fStream) != PLErrors::kNone)
|
||||
return -1;
|
||||
|
||||
ResourceFile *resFile = new ResourceFile();
|
||||
|
@@ -63,22 +63,22 @@ int Count1Resources(UInt32 resType)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HCreateResFile(int refNum, long dirID, const PLPasStr &name)
|
||||
void HCreateResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
OSErr ResError()
|
||||
PLError_t ResError()
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
short FSpOpenResFile(const FSSpec *spec, int permission)
|
||||
short FSpOpenResFile(const VFileSpec &spec, int permission)
|
||||
{
|
||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||
|
||||
return rm->OpenResFork(static_cast<PortabilityLayer::EVirtualDirectory>(spec->parID), PLPasStr(spec->name));
|
||||
return rm->OpenResFork(spec.m_dir, spec.m_name);
|
||||
}
|
||||
|
||||
void CloseResFile(short refNum)
|
||||
@@ -103,7 +103,7 @@ void GetResInfo(Handle res, short *resID, ResType *resType, Str255 resName)
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
short HOpenResFile(short refNum, long parID, const PLPasStr &name, int permissions)
|
||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return 0;
|
||||
|
@@ -19,10 +19,10 @@ Handle Get1Resource(UInt32 resID, int index);
|
||||
Handle Get1IndResource(UInt32 resID, int index);
|
||||
int Count1Resources(UInt32 resType);
|
||||
|
||||
void HCreateResFile(int refNum, long dirID, const PLPasStr &name);
|
||||
OSErr ResError();
|
||||
void HCreateResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name);
|
||||
PLError_t ResError();
|
||||
|
||||
short FSpOpenResFile(const FSSpec *spec, int permission);
|
||||
short FSpOpenResFile(const VFileSpec &spec, int permission);
|
||||
void CloseResFile(short refNum);
|
||||
|
||||
void SetResLoad(Boolean load); // Sets whether resources should be loaded when requested
|
||||
@@ -31,7 +31,7 @@ long GetMaxResourceSize(Handle res);
|
||||
void GetResInfo(Handle res, short *resID, ResType *resType, Str255 resName);
|
||||
|
||||
// This should return -1 on error?
|
||||
short HOpenResFile(short refNum, long parID, const PLPasStr &name, int permissions);
|
||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -232,7 +232,7 @@ namespace PortabilityLayer
|
||||
|
||||
}
|
||||
|
||||
OSErr GetDefaultOutputVolume(long *vol)
|
||||
PLError_t GetDefaultOutputVolume(long *vol)
|
||||
{
|
||||
short leftVol = 0x100;
|
||||
short rightVol = 0x100;
|
||||
@@ -241,12 +241,12 @@ OSErr GetDefaultOutputVolume(long *vol)
|
||||
|
||||
*vol = (leftVol) | (rightVol << 16);
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SetDefaultOutputVolume(long vol)
|
||||
PLError_t SetDefaultOutputVolume(long vol)
|
||||
{
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
|
||||
@@ -259,19 +259,19 @@ void DisposeSndCallBackUPP(SndCallBackUPP upp)
|
||||
{
|
||||
}
|
||||
|
||||
OSErr SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initFlags, SndCallBackUPP callback)
|
||||
PLError_t SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initFlags, SndCallBackUPP callback)
|
||||
{
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
void *storage = mm->Alloc(sizeof(PortabilityLayer::AudioChannelImpl));
|
||||
if (!storage)
|
||||
return mFulErr;
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
PortabilityLayer::HostAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
||||
PortabilityLayer::HostAudioChannel *audioChannel = audioDriver->CreateChannel();
|
||||
if (!audioChannel)
|
||||
{
|
||||
mm->Release(storage);
|
||||
return genericErr;
|
||||
return PLErrors::kAudioError;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *mutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
|
||||
@@ -279,7 +279,7 @@ OSErr SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initF
|
||||
{
|
||||
audioChannel->Destroy();
|
||||
mm->Release(storage);
|
||||
return genericErr;
|
||||
return PLErrors::kAudioError;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostThreadEvent *threadEvent = PortabilityLayer::HostSystemServices::GetInstance()->CreateThreadEvent(true, false);
|
||||
@@ -288,15 +288,15 @@ OSErr SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initF
|
||||
mutex->Destroy();
|
||||
audioChannel->Destroy();
|
||||
mm->Release(storage);
|
||||
return genericErr;
|
||||
return PLErrors::kAudioError;
|
||||
}
|
||||
|
||||
*outChannel = new (storage) PortabilityLayer::AudioChannelImpl(audioChannel, callback, threadEvent, mutex);
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SndDisposeChannel(SndChannelPtr channel, Boolean flush)
|
||||
PLError_t SndDisposeChannel(SndChannelPtr channel, Boolean flush)
|
||||
{
|
||||
if (flush)
|
||||
{
|
||||
@@ -316,20 +316,20 @@ OSErr SndDisposeChannel(SndChannelPtr channel, Boolean flush)
|
||||
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(audioChannelImpl);
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SndDoCommand(SndChannelPtr channel, const SndCommand *command, Boolean failIfFull)
|
||||
PLError_t SndDoCommand(SndChannelPtr channel, const SndCommand *command, Boolean failIfFull)
|
||||
{
|
||||
PortabilityLayer::AudioChannelImpl *audioChannelImpl = static_cast<PortabilityLayer::AudioChannelImpl*>(channel);
|
||||
|
||||
if (!audioChannelImpl->PushCommand(*command, failIfFull == 0))
|
||||
return queueFull;
|
||||
return PLErrors::kAudioError;
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
OSErr SndDoImmediate(SndChannelPtr channel, const SndCommand *command)
|
||||
PLError_t SndDoImmediate(SndChannelPtr channel, const SndCommand *command)
|
||||
{
|
||||
PortabilityLayer::AudioChannelImpl *audioChannelImpl = static_cast<PortabilityLayer::AudioChannelImpl*>(channel);
|
||||
|
||||
@@ -340,8 +340,8 @@ OSErr SndDoImmediate(SndChannelPtr channel, const SndCommand *command)
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
return genericErr;
|
||||
return PLErrors::kAudioError;
|
||||
}
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
@@ -42,15 +42,15 @@ typedef SndCallBackProc SndCallBackUPP;
|
||||
|
||||
// Vol seems to be a packed stereo DWord
|
||||
|
||||
OSErr GetDefaultOutputVolume(long *vol);
|
||||
OSErr SetDefaultOutputVolume(long vol);
|
||||
PLError_t GetDefaultOutputVolume(long *vol);
|
||||
PLError_t SetDefaultOutputVolume(long vol);
|
||||
|
||||
|
||||
SndCallBackUPP NewSndCallBackProc(SndCallBackProc callback);
|
||||
void DisposeSndCallBackUPP(SndCallBackUPP upp);
|
||||
OSErr SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initFlags, SndCallBackUPP callback);
|
||||
OSErr SndDisposeChannel(SndChannelPtr channel, Boolean flush);
|
||||
OSErr SndDoCommand(SndChannelPtr channel, const SndCommand *command, Boolean failIfFull);
|
||||
OSErr SndDoImmediate(SndChannelPtr channel, const SndCommand *command);
|
||||
PLError_t SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initFlags, SndCallBackUPP callback);
|
||||
PLError_t SndDisposeChannel(SndChannelPtr channel, Boolean flush);
|
||||
PLError_t SndDoCommand(SndChannelPtr channel, const SndCommand *command, Boolean failIfFull);
|
||||
PLError_t SndDoImmediate(SndChannelPtr channel, const SndCommand *command);
|
||||
|
||||
#endif
|
||||
|
@@ -180,7 +180,6 @@
|
||||
<ClInclude Include="PascalStr.h" />
|
||||
<ClInclude Include="PascalStrLiteral.h" />
|
||||
<ClInclude Include="PixelFormat.h" />
|
||||
<ClInclude Include="PLAliases.h" />
|
||||
<ClInclude Include="HostMemoryBuffer.h" />
|
||||
<ClInclude Include="HostFileSystem.h" />
|
||||
<ClInclude Include="PLAppleEvents.h" />
|
||||
@@ -284,7 +283,6 @@
|
||||
<ClCompile Include="MenuManager.cpp" />
|
||||
<ClCompile Include="MMBlock.cpp" />
|
||||
<ClCompile Include="MMHandleBlock.cpp" />
|
||||
<ClCompile Include="PLAliases.cpp" />
|
||||
<ClCompile Include="PLAppleEvents.cpp" />
|
||||
<ClCompile Include="PLApplication.cpp" />
|
||||
<ClCompile Include="PLControlDefinitions.cpp" />
|
||||
|
@@ -117,9 +117,6 @@
|
||||
<ClInclude Include="PLDialogs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLAliases.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLStringCompare.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -431,9 +428,6 @@
|
||||
<ClCompile Include="PLAppleEvents.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLAliases.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLStringCompare.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@@ -25,12 +25,12 @@ struct CGraf final
|
||||
{
|
||||
}
|
||||
|
||||
int Init(const Rect &rect, GpPixelFormat_t pixelFormat)
|
||||
PLError_t Init(const Rect &rect, GpPixelFormat_t pixelFormat)
|
||||
{
|
||||
if (int errorCode = m_port.Init(rect, pixelFormat))
|
||||
if (PLError_t errorCode = m_port.Init(rect, pixelFormat))
|
||||
return errorCode;
|
||||
|
||||
return 0;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
bool Resize(const Rect &rect)
|
||||
|
@@ -18,12 +18,10 @@ namespace PortabilityLayer
|
||||
void Init() override;
|
||||
QDPort *GetPort() const override;
|
||||
void SetPort(QDPort *gw) override;
|
||||
int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags) override;
|
||||
PLError_t NewGWorld(CGraf **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
|
||||
void DisposeGWorld(CGraf *gw) override;
|
||||
QDState *GetState() override;
|
||||
|
||||
int DepthForPixelFormat(GpPixelFormat_t pixelFormat) const override;
|
||||
|
||||
static QDManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
@@ -51,37 +49,17 @@ namespace PortabilityLayer
|
||||
m_port = gw;
|
||||
}
|
||||
|
||||
int QDManagerImpl::NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags)
|
||||
PLError_t QDManagerImpl::NewGWorld(CGraf **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable)
|
||||
{
|
||||
GpPixelFormat_t pixelFormat;
|
||||
|
||||
switch (depth)
|
||||
{
|
||||
case 1:
|
||||
pixelFormat = GpPixelFormats::kBW1;
|
||||
break;
|
||||
case 8:
|
||||
pixelFormat = (colorTable == nullptr) ? GpPixelFormats::k8BitStandard : GpPixelFormats::k8BitCustom;
|
||||
break;
|
||||
case 16:
|
||||
pixelFormat = GpPixelFormats::kRGB555;
|
||||
break;
|
||||
case 32:
|
||||
pixelFormat = GpPixelFormats::kRGB32;
|
||||
break;
|
||||
default:
|
||||
return genericErr;
|
||||
}
|
||||
|
||||
void *grafStorage = MemoryManager::GetInstance()->Alloc(sizeof(CGraf));
|
||||
if (!grafStorage)
|
||||
return mFulErr;
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
if (!bounds.IsValid())
|
||||
return genericErr;
|
||||
return PLErrors::kInvalidParameter;
|
||||
|
||||
CGraf *graf = new (grafStorage) CGraf();
|
||||
int initError = graf->Init(bounds, pixelFormat);
|
||||
PLError_t initError = graf->Init(bounds, pixelFormat);
|
||||
if (initError)
|
||||
{
|
||||
DisposeGWorld(graf);
|
||||
@@ -89,7 +67,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
|
||||
*gw = graf;
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
void QDManagerImpl::DisposeGWorld(CGraf *gw)
|
||||
@@ -103,25 +81,6 @@ namespace PortabilityLayer
|
||||
return m_port->GetState();
|
||||
}
|
||||
|
||||
int QDManagerImpl::DepthForPixelFormat(GpPixelFormat_t pixelFormat) const
|
||||
{
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case GpPixelFormats::k8BitStandard:
|
||||
case GpPixelFormats::k8BitCustom:
|
||||
return 8;
|
||||
case GpPixelFormats::kRGB555:
|
||||
return 16;
|
||||
case GpPixelFormats::kRGB24:
|
||||
return 24;
|
||||
case GpPixelFormats::kRGB32:
|
||||
return 32;
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QDManagerImpl *QDManagerImpl::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "GpPixelFormat.h"
|
||||
#include "PLErrorCodes.h"
|
||||
|
||||
struct ColorTable;
|
||||
struct CGraf;
|
||||
@@ -17,13 +18,11 @@ namespace PortabilityLayer
|
||||
virtual void Init() = 0;
|
||||
virtual QDPort *GetPort() const = 0;
|
||||
virtual void SetPort(QDPort *gw) = 0;
|
||||
virtual int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags) = 0;
|
||||
virtual PLError_t NewGWorld(CGraf **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) = 0;
|
||||
virtual void DisposeGWorld(CGraf *gw) = 0;
|
||||
|
||||
virtual QDState *GetState() = 0;
|
||||
|
||||
virtual int DepthForPixelFormat(GpPixelFormat_t pixelFormat) const = 0;
|
||||
|
||||
static QDManager *GetInstance();
|
||||
};
|
||||
}
|
||||
|
@@ -36,15 +36,15 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
int QDPort::Init(const Rect &rect, GpPixelFormat_t pixelFormat)
|
||||
PLError_t QDPort::Init(const Rect &rect, GpPixelFormat_t pixelFormat)
|
||||
{
|
||||
m_pixMap = nullptr;
|
||||
m_pixelFormat = pixelFormat;
|
||||
|
||||
if (!Resize(rect))
|
||||
return mFulErr;
|
||||
return PLErrors::kOutOfMemory;
|
||||
|
||||
return noErr;
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
bool QDPort::Resize(const Rect &rect)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "GpPixelFormat.h"
|
||||
#include "PLErrorCodes.h"
|
||||
#include "QDState.h"
|
||||
|
||||
struct PixMap;
|
||||
@@ -29,7 +30,7 @@ namespace PortabilityLayer
|
||||
explicit QDPort(QDPortType portType);
|
||||
~QDPort();
|
||||
|
||||
int Init(const Rect &rect, GpPixelFormat_t pixelFormat);
|
||||
PLError_t Init(const Rect &rect, GpPixelFormat_t pixelFormat);
|
||||
QDPortType GetPortType() const;
|
||||
|
||||
PixMap **GetPixMap() const;
|
||||
|
@@ -17,7 +17,7 @@ namespace PortabilityLayer
|
||||
|
||||
virtual void SetResLoad(bool load) = 0;
|
||||
|
||||
virtual short OpenResFork(EVirtualDirectory virtualDir, const PLPasStr &filename) = 0;
|
||||
virtual short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||
virtual MMHandleBlock *GetResource(const ResTypeID &resType, int id) = 0;
|
||||
|
||||
virtual short GetCurrentResFile() const = 0;
|
||||
|
@@ -2,15 +2,21 @@
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
enum EVirtualDirectory
|
||||
namespace VirtualDirectories
|
||||
{
|
||||
EVirtualDirectory_Unspecified = 0,
|
||||
enum VirtualDirectory
|
||||
{
|
||||
kUnspecified = 0,
|
||||
|
||||
EVirtualDirectory_ApplicationData = 1,
|
||||
EVirtualDirectory_GameData,
|
||||
EVirtualDirectory_UserData,
|
||||
EVirtualDirectory_Prefs,
|
||||
EVirtualDirectory_Fonts,
|
||||
EVirtualDirectory_Cursors,
|
||||
};
|
||||
kApplicationData = 1,
|
||||
kGameData,
|
||||
kUserData,
|
||||
kPrefs,
|
||||
kFonts,
|
||||
kCursors,
|
||||
kHighScores,
|
||||
};
|
||||
}
|
||||
|
||||
typedef VirtualDirectories::VirtualDirectory VirtualDirectory_t;
|
||||
}
|
||||
|
Reference in New Issue
Block a user