mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-24 07:06:36 +00:00
FS refactoring, 64-bit timestamps
This commit is contained in:
@@ -19,7 +19,7 @@ int main(int argc, const char **argv)
|
|||||||
fprintf(stderr, "File type ID must be 4 characters");
|
fprintf(stderr, "File type ID must be 4 characters");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(argv[4]) != 4)
|
if (strlen(argv[4]) != 4)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "File creator ID must be 4 characters");
|
fprintf(stderr, "File creator ID must be 4 characters");
|
||||||
@@ -29,14 +29,14 @@ int main(int argc, const char **argv)
|
|||||||
FILETIME currentTime;
|
FILETIME currentTime;
|
||||||
GetSystemTimeAsFileTime(¤tTime);
|
GetSystemTimeAsFileTime(¤tTime);
|
||||||
|
|
||||||
SYSTEMTIME epochStart;
|
SYSTEMTIME epochStart;
|
||||||
epochStart.wYear = 1904;
|
epochStart.wYear = 1904;
|
||||||
epochStart.wMonth = 1;
|
epochStart.wMonth = 1;
|
||||||
epochStart.wDayOfWeek = 5;
|
epochStart.wDayOfWeek = 5;
|
||||||
epochStart.wDay = 1;
|
epochStart.wDay = 1;
|
||||||
epochStart.wHour = 0;
|
epochStart.wHour = 0;
|
||||||
epochStart.wMinute = 0;
|
epochStart.wMinute = 0;
|
||||||
epochStart.wSecond = 0;
|
epochStart.wSecond = 0;
|
||||||
epochStart.wMilliseconds = 0;
|
epochStart.wMilliseconds = 0;
|
||||||
|
|
||||||
FILETIME epochStartFT;
|
FILETIME epochStartFT;
|
||||||
@@ -61,19 +61,19 @@ int main(int argc, const char **argv)
|
|||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
if (!strcmp(arg, "locked"))
|
if (!strcmp(arg, "locked"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_LOCKED;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_LOCKED;
|
||||||
else if (!strcmp(arg, "invisible"))
|
else if (!strcmp(arg, "invisible"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_INVISIBLE;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_INVISIBLE;
|
||||||
else if (!strcmp(arg, "bundle"))
|
else if (!strcmp(arg, "bundle"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_BUNDLE;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_BUNDLE;
|
||||||
else if (!strcmp(arg, "system"))
|
else if (!strcmp(arg, "system"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_SYSTEM;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_SYSTEM;
|
||||||
else if (!strcmp(arg, "copyprotected"))
|
else if (!strcmp(arg, "copyprotected"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_COPY_PROTECTED;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_COPY_PROTECTED;
|
||||||
else if (!strcmp(arg, "busy"))
|
else if (!strcmp(arg, "busy"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_BUSY;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_BUSY;
|
||||||
else if (!strcmp(arg, "changed"))
|
else if (!strcmp(arg, "changed"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_CHANGED;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_CHANGED;
|
||||||
else if (!strcmp(arg, "inited"))
|
else if (!strcmp(arg, "inited"))
|
||||||
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_INITED;
|
mfp.m_finderFlags |= PortabilityLayer::FINDER_FILE_FLAG_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +91,6 @@ int main(int argc, const char **argv)
|
|||||||
fwrite(mps.m_data, PortabilityLayer::MacFilePropertiesSerialized::kSize, 1, file);
|
fwrite(mps.m_data, PortabilityLayer::MacFilePropertiesSerialized::kSize, 1, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "DialogUtils.h"
|
#include "DialogUtils.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
|
#include "HostSystemServices.h"
|
||||||
#include "ScanlineMask.h"
|
#include "ScanlineMask.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -143,13 +144,15 @@ static void UnHiLiteOkayButton (void)
|
|||||||
static void UpdateMainPict (DialogPtr theDial)
|
static void UpdateMainPict (DialogPtr theDial)
|
||||||
{
|
{
|
||||||
Str255 theStr, theStr2;
|
Str255 theStr, theStr2;
|
||||||
long totalSize, contigSize;
|
uint64_t freeMemory;
|
||||||
|
|
||||||
DrawDialog(theDial);
|
DrawDialog(theDial);
|
||||||
|
|
||||||
|
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic();
|
||||||
|
|
||||||
PasStringCopy(PSTR("Memory: "), theStr); // display free memory
|
PasStringCopy(PSTR("Memory: "), theStr); // display free memory
|
||||||
PurgeSpace(&totalSize, &contigSize);
|
|
||||||
totalSize /= 1024;
|
long totalSize = static_cast<long>(freeMemory / 1024);
|
||||||
NumToString(totalSize, theStr2);
|
NumToString(totalSize, theStr2);
|
||||||
PasStringConcat(theStr, theStr2);
|
PasStringConcat(theStr, theStr2);
|
||||||
PasStringConcat(theStr, PSTR("K"));
|
PasStringConcat(theStr, PSTR("K"));
|
||||||
|
@@ -631,14 +631,16 @@ void GetHighScoreBanner (void)
|
|||||||
Boolean OpenHighScoresFile (const VFileSpec &scoreSpec, PortabilityLayer::IOStream *&scoresStream)
|
Boolean OpenHighScoresFile (const VFileSpec &scoreSpec, PortabilityLayer::IOStream *&scoresStream)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
|
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||||
|
|
||||||
theErr = PortabilityLayer::FileManager::GetInstance()->OpenFileDF(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
|
theErr = fm->OpenFileData(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
|
||||||
if (theErr == PLErrors::kFileNotFound)
|
if (theErr == PLErrors::kFileNotFound)
|
||||||
{
|
{
|
||||||
theErr = FSpCreate(scoreSpec, 'ozm5', 'gliS');
|
theErr = fm->CreateFileAtCurrentTime(scoreSpec.m_dir, scoreSpec.m_name, 'ozm5', 'gliS');
|
||||||
if (!CheckFileError(theErr, PSTR("New High Scores File")))
|
if (!CheckFileError(theErr, PSTR("New High Scores File")))
|
||||||
return (false);
|
return (false);
|
||||||
theErr = FSpOpenDF(scoreSpec, fsCurPerm, scoresStream);
|
theErr = fm->OpenFileData(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
|
||||||
if (!CheckFileError(theErr, PSTR("High Score")))
|
if (!CheckFileError(theErr, PSTR("High Score")))
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ Boolean CreateNewHouse (void)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
theErr = FSpCreate(theSpec, 'ozm5', 'gliH');
|
theErr = fm->CreateFileAtCurrentTime(theSpec.m_dir, theSpec.m_name, 'ozm5', 'gliH');
|
||||||
if (!CheckFileError(theErr, PSTR("New House")))
|
if (!CheckFileError(theErr, PSTR("New House")))
|
||||||
return (false);
|
return (false);
|
||||||
HCreateResFile(theSpec.m_dir, theSpec.m_name);
|
HCreateResFile(theSpec.m_dir, theSpec.m_name);
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
|
#include "FileManager.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
#include "IOStream.h"
|
#include "IOStream.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
@@ -182,7 +183,7 @@ Boolean OpenHouse (void)
|
|||||||
|
|
||||||
houseIsReadOnly = IsFileReadOnly(theHousesSpecs[thisHouseIndex]);
|
houseIsReadOnly = IsFileReadOnly(theHousesSpecs[thisHouseIndex]);
|
||||||
|
|
||||||
theErr = FSpOpenDF(theHousesSpecs[thisHouseIndex], fsCurPerm, houseStream);
|
theErr = PortabilityLayer::FileManager::GetInstance()->OpenFileData(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name, PortabilityLayer::EFilePermission_Any, houseStream);
|
||||||
if (!CheckFileError(theErr, thisHouseName))
|
if (!CheckFileError(theErr, thisHouseName))
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
|
@@ -44,20 +44,22 @@ Boolean WritePrefs (const prefsInfo *thePrefs)
|
|||||||
PortabilityLayer::IOStream *fileStream;
|
PortabilityLayer::IOStream *fileStream;
|
||||||
long byteCount;
|
long byteCount;
|
||||||
Str255 fileName;
|
Str255 fileName;
|
||||||
|
|
||||||
|
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||||
|
|
||||||
PasStringCopy(kPrefFileName, fileName);
|
PasStringCopy(kPrefFileName, fileName);
|
||||||
|
|
||||||
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
|
if (!fm->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
|
||||||
{
|
{
|
||||||
theErr = FSpCreate(theSpecs, kPrefCreatorType, kPrefFileType);
|
theErr = fm->CreateFileAtCurrentTime(theSpecs.m_dir, theSpecs.m_name, kPrefCreatorType, kPrefFileType);
|
||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
{
|
{
|
||||||
CheckFileError(theErr, PSTR("Preferences"));
|
CheckFileError(theErr, PSTR("Preferences"));
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theErr = FSpOpenDF(theSpecs, fsRdWrPerm, fileStream);
|
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Write, fileStream);
|
||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
{
|
{
|
||||||
CheckFileError(theErr, PSTR("Preferences"));
|
CheckFileError(theErr, PSTR("Preferences"));
|
||||||
@@ -98,6 +100,8 @@ PLError_t ReadPrefs (prefsInfo *thePrefs)
|
|||||||
long byteCount;
|
long byteCount;
|
||||||
VFileSpec theSpecs;
|
VFileSpec theSpecs;
|
||||||
Str255 fileName;
|
Str255 fileName;
|
||||||
|
|
||||||
|
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||||
|
|
||||||
PasStringCopy(kPrefFileName, fileName);
|
PasStringCopy(kPrefFileName, fileName);
|
||||||
|
|
||||||
@@ -106,7 +110,7 @@ PLError_t ReadPrefs (prefsInfo *thePrefs)
|
|||||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
||||||
return PLErrors::kFileNotFound;
|
return PLErrors::kFileNotFound;
|
||||||
|
|
||||||
theErr = FSpOpenDF(theSpecs, fsRdWrPerm, fileStream);
|
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Read, fileStream);
|
||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
{
|
{
|
||||||
CheckFileError(theErr, PSTR("Preferences"));
|
CheckFileError(theErr, PSTR("Preferences"));
|
||||||
@@ -139,12 +143,7 @@ Boolean DeletePrefs ()
|
|||||||
|
|
||||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||||
|
|
||||||
theErr = FSpDelete(theSpecs);
|
return PortabilityLayer::FileManager::GetInstance()->DeleteFile(theSpecs.m_dir, theSpecs.m_name);
|
||||||
|
|
||||||
if (theErr != PLErrors::kNone)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- LoadPrefs
|
//-------------------------------------------------------------- LoadPrefs
|
||||||
|
@@ -7,7 +7,7 @@ static volatile uint64_t gs_prioritiesBlob = 0;
|
|||||||
|
|
||||||
SoundSyncState SoundSync_ReadAll()
|
SoundSyncState SoundSync_ReadAll()
|
||||||
{
|
{
|
||||||
const uint16_t priorities = gs_prioritiesBlob;
|
const uint64_t priorities = gs_prioritiesBlob;
|
||||||
|
|
||||||
SoundSyncState state;
|
SoundSyncState state;
|
||||||
state.priority0 = static_cast<uint16_t>((priorities >> 0) & 0xffff);
|
state.priority0 = static_cast<uint16_t>((priorities >> 0) & 0xffff);
|
||||||
|
@@ -13,10 +13,29 @@ GpSystemServices_Win32::GpSystemServices_Win32()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GpSystemServices_Win32::GetTime() const
|
int64_t GpSystemServices_Win32::GetTime() const
|
||||||
{
|
{
|
||||||
//PL_NotYetImplemented_TODO("Time");
|
SYSTEMTIME epochStart;
|
||||||
return 0;
|
epochStart.wYear = 1904;
|
||||||
|
epochStart.wMonth = 1;
|
||||||
|
epochStart.wDayOfWeek = 5;
|
||||||
|
epochStart.wDay = 1;
|
||||||
|
epochStart.wHour = 0;
|
||||||
|
epochStart.wMinute = 0;
|
||||||
|
epochStart.wSecond = 0;
|
||||||
|
epochStart.wMilliseconds = 0;
|
||||||
|
|
||||||
|
FILETIME epochStartFT;
|
||||||
|
if (!SystemTimeToFileTime(&epochStart, &epochStartFT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
FILETIME currentTime;
|
||||||
|
GetSystemTimeAsFileTime(¤tTime);
|
||||||
|
|
||||||
|
int64_t epochStart64 = (static_cast<int64_t>(epochStartFT.dwLowDateTime) & 0xffffffff) | (static_cast<int64_t>(epochStartFT.dwHighDateTime) << 32);
|
||||||
|
int64_t currentTime64 = (static_cast<int64_t>(currentTime.dwLowDateTime) & 0xffffffff) | (static_cast<int64_t>(currentTime.dwHighDateTime) << 32);
|
||||||
|
|
||||||
|
return currentTime64 - epochStart64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
|
void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
|
||||||
@@ -36,12 +55,21 @@ PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateMutex()
|
|||||||
{
|
{
|
||||||
return GpMutex_Win32::Create();
|
return GpMutex_Win32::Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
PortabilityLayer::HostThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
|
PortabilityLayer::HostThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
|
||||||
{
|
{
|
||||||
return GpThreadEvent_Win32::Create(autoReset, startSignaled);
|
return GpThreadEvent_Win32::Create(autoReset, startSignaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t GpSystemServices_Win32::GetFreeMemoryCosmetic() const
|
||||||
|
{
|
||||||
|
MEMORYSTATUSEX memStatus;
|
||||||
|
if (!GlobalMemoryStatusEx(&memStatus))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return memStatus.ullAvailPhys;
|
||||||
|
}
|
||||||
|
|
||||||
GpSystemServices_Win32 *GpSystemServices_Win32::GetInstance()
|
GpSystemServices_Win32 *GpSystemServices_Win32::GetInstance()
|
||||||
{
|
{
|
||||||
return &ms_instance;
|
return &ms_instance;
|
||||||
|
@@ -15,10 +15,11 @@ class GpSystemServices_Win32 final : public PortabilityLayer::HostSystemServices
|
|||||||
public:
|
public:
|
||||||
GpSystemServices_Win32();
|
GpSystemServices_Win32();
|
||||||
|
|
||||||
uint32_t GetTime() const override;
|
int64_t GetTime() const override;
|
||||||
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
||||||
PortabilityLayer::HostMutex *CreateMutex() override;
|
PortabilityLayer::HostMutex *CreateMutex() override;
|
||||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||||
|
uint64_t GetFreeMemoryCosmetic() const override;
|
||||||
|
|
||||||
static GpSystemServices_Win32 *GetInstance();
|
static GpSystemServices_Win32 *GetInstance();
|
||||||
|
|
||||||
|
@@ -1,37 +1,54 @@
|
|||||||
#include "ByteSwap.h"
|
#include "ByteSwap.h"
|
||||||
|
#include "CoreDefs.h"
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
namespace ByteSwap
|
namespace ByteSwap
|
||||||
{
|
{
|
||||||
void BigInt16(int16_t &v)
|
template<class TNumberType, class TUnsignedType>
|
||||||
{
|
void SwapArbitrary(TNumberType &v)
|
||||||
const uint8_t *asU8 = reinterpret_cast<const uint8_t*>(&v);
|
{
|
||||||
const int8_t *asS8 = reinterpret_cast<const int8_t*>(&v);
|
PL_STATIC_ASSERT(sizeof(TNumberType) == sizeof(TUnsignedType));
|
||||||
|
|
||||||
|
uint8_t bytes[sizeof(TNumberType)];
|
||||||
|
for (size_t i = 0; i < sizeof(TNumberType); i++)
|
||||||
|
bytes[i] = reinterpret_cast<const uint8_t*>(&v)[i];
|
||||||
|
|
||||||
|
TUnsignedType result = 0;
|
||||||
|
for (size_t i = 0; i < sizeof(TNumberType); i++)
|
||||||
|
result |= static_cast<TUnsignedType>(bytes[i]) << (sizeof(TUnsignedType) * 8 - 8 - (i * 8));
|
||||||
|
|
||||||
v = static_cast<int16_t>((asS8[0] << 8) | asU8[1]);
|
v = static_cast<TNumberType>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BigInt16(int16_t &v)
|
||||||
|
{
|
||||||
|
SwapArbitrary<int16_t, uint16_t>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigInt32(int32_t &v)
|
void BigInt32(int32_t &v)
|
||||||
{
|
{
|
||||||
const uint8_t *asU8 = reinterpret_cast<const uint8_t*>(&v);
|
SwapArbitrary<int32_t, uint32_t>(v);
|
||||||
const int8_t *asS8 = reinterpret_cast<const int8_t*>(&v);
|
|
||||||
|
|
||||||
v = static_cast<int32_t>((asS8[0] << 24) | (asU8[1] << 16) | (asU8[2] << 8) | asU8[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigUInt16(uint16_t &v)
|
void BigInt64(int64_t &v)
|
||||||
{
|
{
|
||||||
const uint8_t *asU8 = reinterpret_cast<const uint8_t*>(&v);
|
SwapArbitrary<int64_t, uint64_t>(v);
|
||||||
|
}
|
||||||
|
|
||||||
v = static_cast<uint16_t>((asU8[0] << 8) | asU8[1]);
|
void BigUInt16(uint16_t &v)
|
||||||
|
{
|
||||||
|
SwapArbitrary<uint16_t, uint16_t>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigUInt32(uint32_t &v)
|
void BigUInt32(uint32_t &v)
|
||||||
{
|
{
|
||||||
const uint8_t *asU8 = reinterpret_cast<const uint8_t*>(&v);
|
SwapArbitrary<uint32_t, uint32_t>(v);
|
||||||
|
}
|
||||||
|
|
||||||
v = static_cast<uint32_t>((asU8[0] << 24) | (asU8[1] << 16) | (asU8[2] << 8) | asU8[3]);
|
void BigUInt64(uint64_t &v)
|
||||||
|
{
|
||||||
|
SwapArbitrary<uint64_t, uint64_t>(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,10 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
void BigInt16(int16_t &v);
|
void BigInt16(int16_t &v);
|
||||||
void BigInt32(int32_t &v);
|
void BigInt32(int32_t &v);
|
||||||
|
void BigInt64(int64_t &v);
|
||||||
void BigUInt16(uint16_t &v);
|
void BigUInt16(uint16_t &v);
|
||||||
void BigUInt32(uint32_t &v);
|
void BigUInt32(uint32_t &v);
|
||||||
|
void BigUInt64(uint64_t &v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLErrorCodes.h"
|
#include "PLErrorCodes.h"
|
||||||
#include "ResTypeID.h"
|
#include "ResTypeID.h"
|
||||||
|
#include "HostSystemServices.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -21,13 +22,14 @@ namespace PortabilityLayer
|
|||||||
bool DeleteFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
bool DeleteFile(VirtualDirectory_t dirID, const PLPasStr &filename) override;
|
||||||
|
|
||||||
PLError_t CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp) override;
|
PLError_t CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp) override;
|
||||||
|
PLError_t CreateFileAtCurrentTime(VirtualDirectory_t dirID, const PLPasStr &filename, const ResTypeID &fileCreator, const ResTypeID &fileType) override;
|
||||||
|
|
||||||
PLError_t OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outRefNum) override;
|
PLError_t OpenFileData(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;
|
PLError_t OpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outRefNum) override;
|
||||||
bool ReadFileProperties(VirtualDirectory_t dirID, const PLPasStr &filename, MacFileProperties &properties) 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 RawOpenFileData(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;
|
PLError_t RawOpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) override;
|
||||||
|
|
||||||
static FileManagerImpl *GetInstance();
|
static FileManagerImpl *GetInstance();
|
||||||
|
|
||||||
@@ -86,12 +88,22 @@ namespace PortabilityLayer
|
|||||||
return PLErrors::kNone;
|
return PLErrors::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t FileManagerImpl::OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
PLError_t FileManagerImpl::CreateFileAtCurrentTime(VirtualDirectory_t dirID, const PLPasStr &filename, const ResTypeID &fileCreator, const ResTypeID &fileType)
|
||||||
|
{
|
||||||
|
MacFileProperties mfp;
|
||||||
|
fileCreator.ExportAsChars(mfp.m_fileCreator);
|
||||||
|
fileType.ExportAsChars(mfp.m_fileType);
|
||||||
|
mfp.m_creationDate = mfp.m_modifiedDate = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
|
||||||
|
|
||||||
|
return CreateFile(dirID, filename, mfp);
|
||||||
|
}
|
||||||
|
|
||||||
|
PLError_t FileManagerImpl::OpenFileData(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
||||||
{
|
{
|
||||||
return OpenFileFork(dirID, filename, ".gpd", permission, outStream);
|
return OpenFileFork(dirID, filename, ".gpd", permission, outStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t FileManagerImpl::OpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
PLError_t FileManagerImpl::OpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, IOStream *&outStream)
|
||||||
{
|
{
|
||||||
return OpenFileFork(dirID, filename, ".gpr", permission, outStream);
|
return OpenFileFork(dirID, filename, ".gpr", permission, outStream);
|
||||||
}
|
}
|
||||||
@@ -113,12 +125,12 @@ namespace PortabilityLayer
|
|||||||
return readOk;
|
return readOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t FileManagerImpl::RawOpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
PLError_t FileManagerImpl::RawOpenFileData(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
||||||
{
|
{
|
||||||
return RawOpenFileFork(dirID, filename, ".gpd", permission, ignoreMeta, false, outStream);
|
return RawOpenFileFork(dirID, filename, ".gpd", permission, ignoreMeta, false, outStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t FileManagerImpl::RawOpenFileRF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
PLError_t FileManagerImpl::RawOpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission permission, bool ignoreMeta, IOStream *&outStream)
|
||||||
{
|
{
|
||||||
return RawOpenFileFork(dirID, filename, ".gpr", permission, ignoreMeta, false, outStream);
|
return RawOpenFileFork(dirID, filename, ".gpr", permission, ignoreMeta, false, outStream);
|
||||||
}
|
}
|
||||||
|
@@ -25,13 +25,14 @@ namespace PortabilityLayer
|
|||||||
virtual bool DeleteFile(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 CreateFile(VirtualDirectory_t dirID, const PLPasStr &filename, const MacFileProperties &mfp) = 0;
|
||||||
|
virtual PLError_t CreateFileAtCurrentTime(VirtualDirectory_t dirID, const PLPasStr &filename, const ResTypeID &fileCreator, const ResTypeID &fileType) = 0;
|
||||||
|
|
||||||
virtual PLError_t OpenFileDF(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outStream) = 0;
|
virtual PLError_t OpenFileData(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 PLError_t OpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, IOStream *&outStream) = 0;
|
||||||
virtual bool ReadFileProperties(VirtualDirectory_t dirID, const PLPasStr &filename, MacFileProperties &properties) = 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 RawOpenFileData(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;
|
virtual PLError_t RawOpenFileResources(VirtualDirectory_t dirID, const PLPasStr &filename, EFilePermission filePermission, bool ignoreMeta, IOStream *&outStream) = 0;
|
||||||
|
|
||||||
static FileManager *GetInstance();
|
static FileManager *GetInstance();
|
||||||
};
|
};
|
||||||
|
@@ -16,10 +16,11 @@ namespace PortabilityLayer
|
|||||||
class HostSystemServices
|
class HostSystemServices
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual uint32_t GetTime() const = 0;
|
virtual int64_t GetTime() const = 0;
|
||||||
virtual void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const = 0;
|
virtual void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const = 0;
|
||||||
virtual HostMutex *CreateMutex() = 0;
|
virtual HostMutex *CreateMutex() = 0;
|
||||||
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
|
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
|
||||||
|
virtual size_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate
|
||||||
|
|
||||||
static void SetInstance(HostSystemServices *instance);
|
static void SetInstance(HostSystemServices *instance);
|
||||||
static HostSystemServices *GetInstance();
|
static HostSystemServices *GetInstance();
|
||||||
|
@@ -33,8 +33,8 @@ namespace PortabilityLayer
|
|||||||
PortabilityLayer::ByteSwap::BigInt16(props.m_xPos);
|
PortabilityLayer::ByteSwap::BigInt16(props.m_xPos);
|
||||||
PortabilityLayer::ByteSwap::BigInt16(props.m_yPos);
|
PortabilityLayer::ByteSwap::BigInt16(props.m_yPos);
|
||||||
PortabilityLayer::ByteSwap::BigUInt16(props.m_finderFlags);
|
PortabilityLayer::ByteSwap::BigUInt16(props.m_finderFlags);
|
||||||
PortabilityLayer::ByteSwap::BigUInt32(props.m_creationDate);
|
PortabilityLayer::ByteSwap::BigInt64(props.m_creationDate);
|
||||||
PortabilityLayer::ByteSwap::BigUInt32(props.m_modifiedDate);
|
PortabilityLayer::ByteSwap::BigInt64(props.m_modifiedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacFilePropertiesSerialized::Serialize(const MacFileProperties &props)
|
void MacFilePropertiesSerialized::Serialize(const MacFileProperties &props)
|
||||||
@@ -57,7 +57,7 @@ namespace PortabilityLayer
|
|||||||
memcpy(m_data + kOffsetYPos, &yPos, 2);
|
memcpy(m_data + kOffsetYPos, &yPos, 2);
|
||||||
memcpy(m_data + kOffsetFinderFlags, &finderFlags, 2);
|
memcpy(m_data + kOffsetFinderFlags, &finderFlags, 2);
|
||||||
memcpy(m_data + kProtected, &props.m_protected, 1);
|
memcpy(m_data + kProtected, &props.m_protected, 1);
|
||||||
memcpy(m_data + kCreationDate, &creationDate, 4);
|
memcpy(m_data + kCreationDate, &creationDate, 8);
|
||||||
memcpy(m_data + kModifiedDate, &modifiedDate, 4);
|
memcpy(m_data + kModifiedDate, &modifiedDate, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,8 +27,8 @@ namespace PortabilityLayer
|
|||||||
int16_t m_yPos;
|
int16_t m_yPos;
|
||||||
uint16_t m_finderFlags;
|
uint16_t m_finderFlags;
|
||||||
uint8_t m_protected;
|
uint8_t m_protected;
|
||||||
uint32_t m_creationDate;
|
int64_t m_creationDate;
|
||||||
uint32_t m_modifiedDate;
|
int64_t m_modifiedDate;
|
||||||
|
|
||||||
void Serialize(void *buffer) const;
|
void Serialize(void *buffer) const;
|
||||||
void Deserialize(const void *buffer);
|
void Deserialize(const void *buffer);
|
||||||
@@ -43,9 +43,9 @@ namespace PortabilityLayer
|
|||||||
static const unsigned int kOffsetFinderFlags = 12;
|
static const unsigned int kOffsetFinderFlags = 12;
|
||||||
static const unsigned int kProtected = 14;
|
static const unsigned int kProtected = 14;
|
||||||
static const unsigned int kCreationDate = 15;
|
static const unsigned int kCreationDate = 15;
|
||||||
static const unsigned int kModifiedDate = 19;
|
static const unsigned int kModifiedDate = 23;
|
||||||
|
|
||||||
static const unsigned int kSize = 23;
|
static const unsigned int kSize = 31;
|
||||||
|
|
||||||
uint8_t m_data[kSize];
|
uint8_t m_data[kSize];
|
||||||
|
|
||||||
|
@@ -677,53 +677,6 @@ VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr
|
|||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 PLErrors::kNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t FSpOpenDF(const VFileSpec &spec, int permission, PortabilityLayer::IOStream *&stream)
|
|
||||||
{
|
|
||||||
PortabilityLayer::EFilePermission perm = PortabilityLayer::EFilePermission_Any;
|
|
||||||
switch (permission)
|
|
||||||
{
|
|
||||||
case fsRdPerm:
|
|
||||||
perm = PortabilityLayer::EFilePermission_Read;
|
|
||||||
break;
|
|
||||||
case fsWrPerm:
|
|
||||||
case fsRdWrPerm:
|
|
||||||
perm = PortabilityLayer::EFilePermission_ReadWrite;
|
|
||||||
break;
|
|
||||||
case fsCurPerm:
|
|
||||||
perm = PortabilityLayer::EFilePermission_Any;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return PLErrors::kAccessDenied;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PortabilityLayer::FileManager::GetInstance()->OpenFileDF(spec.m_dir, spec.m_name, perm, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t FSpDelete(const VFileSpec &spec)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return PLErrors::kNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfo)
|
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfo)
|
||||||
{
|
{
|
||||||
PortabilityLayer::MacFileProperties mfp;
|
PortabilityLayer::MacFileProperties mfp;
|
||||||
@@ -736,18 +689,6 @@ PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfo)
|
|||||||
return PLErrors::kNone;
|
return PLErrors::kNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t SetEOF(short refNum, long byteCount)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return PLErrors::kNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return PLErrors::kNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID)
|
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID)
|
||||||
{
|
{
|
||||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||||
@@ -1029,20 +970,6 @@ void DisposePtr(void *ptr)
|
|||||||
PL_NotYetImplemented();
|
PL_NotYetImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PurgeSpace(long *totalFree, long *contiguousFree)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HSetState(Handle handle, char state)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
char HGetState(Handle handle)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlockMove(const void *src, void *dest, Size size)
|
void BlockMove(const void *src, void *dest, Size size)
|
||||||
{
|
{
|
||||||
memcpy(dest, src, size);
|
memcpy(dest, src, size);
|
||||||
|
@@ -300,17 +300,11 @@ UInt32 FreeMem();
|
|||||||
|
|
||||||
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
||||||
|
|
||||||
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
|
void GetIndString(unsigned char *str, int stringsID, int fnameIndex); // Fetches a string resource of some sort
|
||||||
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous);
|
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous);
|
||||||
|
|
||||||
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName);
|
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName);
|
||||||
|
|
||||||
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);
|
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfoOut);
|
||||||
|
|
||||||
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async);
|
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async);
|
||||||
@@ -348,11 +342,8 @@ void *NewPtr(Size size);
|
|||||||
void *NewPtrClear(Size size);
|
void *NewPtrClear(Size size);
|
||||||
void DisposePtr(void *ptr);
|
void DisposePtr(void *ptr);
|
||||||
|
|
||||||
Size MaxMem(Size *growBytes);
|
|
||||||
void PurgeSpace(long *totalFree, long *contiguousFree);
|
void PurgeSpace(long *totalFree, long *contiguousFree);
|
||||||
|
|
||||||
PLError_t MemError();
|
|
||||||
|
|
||||||
void BlockMove(const void *src, void *dest, Size size);
|
void BlockMove(const void *src, void *dest, Size size);
|
||||||
|
|
||||||
Boolean WaitNextEvent(int eventMask, EventRecord *eventOut, long sleep, void *unknown);
|
Boolean WaitNextEvent(int eventMask, EventRecord *eventOut, long sleep, void *unknown);
|
||||||
|
@@ -109,7 +109,7 @@ namespace PortabilityLayer
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
IOStream *fStream = nullptr;
|
IOStream *fStream = nullptr;
|
||||||
if (FileManager::GetInstance()->RawOpenFileRF(virtualDir, filename, EFilePermission_Read, true, fStream) != PLErrors::kNone)
|
if (FileManager::GetInstance()->RawOpenFileResources(virtualDir, filename, EFilePermission_Read, true, fStream) != PLErrors::kNone)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ResourceFile *resFile = new ResourceFile();
|
ResourceFile *resFile = new ResourceFile();
|
||||||
|
@@ -1,68 +1,75 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __PL_RES_TYPE_ID_H__
|
#ifndef __PL_RES_TYPE_ID_H__
|
||||||
#define __PL_RES_TYPE_ID_H__
|
#define __PL_RES_TYPE_ID_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
class ResTypeID
|
class ResTypeID
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResTypeID();
|
ResTypeID();
|
||||||
ResTypeID(int32_t i);
|
ResTypeID(int32_t i);
|
||||||
ResTypeID(const ResTypeID &other);
|
ResTypeID(const ResTypeID &other);
|
||||||
explicit ResTypeID(const char *chars);
|
explicit ResTypeID(const char *chars);
|
||||||
|
|
||||||
ResTypeID &operator=(const ResTypeID &other);
|
ResTypeID &operator=(const ResTypeID &other);
|
||||||
bool operator==(const ResTypeID &other) const;
|
bool operator==(const ResTypeID &other) const;
|
||||||
bool operator!=(const ResTypeID &other) const;
|
bool operator!=(const ResTypeID &other) const;
|
||||||
|
|
||||||
private:
|
void ExportAsChars(char *chars) const;
|
||||||
char m_id[4];
|
|
||||||
};
|
private:
|
||||||
}
|
char m_id[4];
|
||||||
|
};
|
||||||
#include "ResTypeIDCodec.h"
|
}
|
||||||
#include <string.h>
|
|
||||||
|
#include "ResTypeIDCodec.h"
|
||||||
namespace PortabilityLayer
|
#include <string.h>
|
||||||
{
|
|
||||||
inline ResTypeID::ResTypeID()
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
m_id[0] = m_id[1] = m_id[2] = m_id[3] = 0;
|
inline ResTypeID::ResTypeID()
|
||||||
}
|
{
|
||||||
|
m_id[0] = m_id[1] = m_id[2] = m_id[3] = 0;
|
||||||
inline ResTypeID::ResTypeID(int32_t i)
|
}
|
||||||
{
|
|
||||||
ResTypeIDCodec::Encode(i, m_id);
|
inline ResTypeID::ResTypeID(int32_t i)
|
||||||
}
|
{
|
||||||
|
ResTypeIDCodec::Encode(i, m_id);
|
||||||
inline ResTypeID::ResTypeID(const ResTypeID &other)
|
}
|
||||||
{
|
|
||||||
memcpy(m_id, other.m_id, 4);
|
inline ResTypeID::ResTypeID(const ResTypeID &other)
|
||||||
}
|
{
|
||||||
|
memcpy(m_id, other.m_id, 4);
|
||||||
inline ResTypeID::ResTypeID(const char *chars)
|
}
|
||||||
{
|
|
||||||
memcpy(m_id, chars, 4);
|
inline ResTypeID::ResTypeID(const char *chars)
|
||||||
}
|
{
|
||||||
|
memcpy(m_id, chars, 4);
|
||||||
inline ResTypeID &ResTypeID::operator=(const ResTypeID &other)
|
}
|
||||||
{
|
|
||||||
memcpy(m_id, other.m_id, 4);
|
inline ResTypeID &ResTypeID::operator=(const ResTypeID &other)
|
||||||
return *this;
|
{
|
||||||
}
|
memcpy(m_id, other.m_id, 4);
|
||||||
|
return *this;
|
||||||
inline bool ResTypeID::operator==(const ResTypeID &other) const
|
}
|
||||||
{
|
|
||||||
return memcmp(m_id, other.m_id, 4) == 0;
|
inline bool ResTypeID::operator==(const ResTypeID &other) const
|
||||||
}
|
{
|
||||||
|
return memcmp(m_id, other.m_id, 4) == 0;
|
||||||
inline bool ResTypeID::operator!=(const ResTypeID &other) const
|
}
|
||||||
{
|
|
||||||
return memcmp(m_id, other.m_id, 4) != 0;
|
inline bool ResTypeID::operator!=(const ResTypeID &other) const
|
||||||
}
|
{
|
||||||
}
|
return memcmp(m_id, other.m_id, 4) != 0;
|
||||||
|
}
|
||||||
#endif
|
|
||||||
|
inline void ResTypeID::ExportAsChars(char *chars) const
|
||||||
|
{
|
||||||
|
memcpy(chars, m_id, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user