mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
FS refactoring, 64-bit timestamps
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "DialogUtils.h"
|
||||
#include "Environ.h"
|
||||
#include "Externs.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "ScanlineMask.h"
|
||||
|
||||
|
||||
@@ -143,13 +144,15 @@ static void UnHiLiteOkayButton (void)
|
||||
static void UpdateMainPict (DialogPtr theDial)
|
||||
{
|
||||
Str255 theStr, theStr2;
|
||||
long totalSize, contigSize;
|
||||
uint64_t freeMemory;
|
||||
|
||||
DrawDialog(theDial);
|
||||
|
||||
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic();
|
||||
|
||||
PasStringCopy(PSTR("Memory: "), theStr); // display free memory
|
||||
PurgeSpace(&totalSize, &contigSize);
|
||||
totalSize /= 1024;
|
||||
|
||||
long totalSize = static_cast<long>(freeMemory / 1024);
|
||||
NumToString(totalSize, theStr2);
|
||||
PasStringConcat(theStr, theStr2);
|
||||
PasStringConcat(theStr, PSTR("K"));
|
||||
|
@@ -631,14 +631,16 @@ void GetHighScoreBanner (void)
|
||||
Boolean OpenHighScoresFile (const VFileSpec &scoreSpec, PortabilityLayer::IOStream *&scoresStream)
|
||||
{
|
||||
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)
|
||||
{
|
||||
theErr = FSpCreate(scoreSpec, 'ozm5', 'gliS');
|
||||
theErr = fm->CreateFileAtCurrentTime(scoreSpec.m_dir, scoreSpec.m_name, 'ozm5', 'gliS');
|
||||
if (!CheckFileError(theErr, PSTR("New High Scores File")))
|
||||
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")))
|
||||
return (false);
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ Boolean CreateNewHouse (void)
|
||||
return (false);
|
||||
}
|
||||
|
||||
theErr = FSpCreate(theSpec, 'ozm5', 'gliH');
|
||||
theErr = fm->CreateFileAtCurrentTime(theSpec.m_dir, theSpec.m_name, 'ozm5', 'gliH');
|
||||
if (!CheckFileError(theErr, PSTR("New House")))
|
||||
return (false);
|
||||
HCreateResFile(theSpec.m_dir, theSpec.m_name);
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "PLPasStr.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "FileManager.h"
|
||||
#include "House.h"
|
||||
#include "IOStream.h"
|
||||
#include "ObjectEdit.h"
|
||||
@@ -182,7 +183,7 @@ Boolean OpenHouse (void)
|
||||
|
||||
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))
|
||||
return (false);
|
||||
|
||||
|
@@ -44,20 +44,22 @@ Boolean WritePrefs (const prefsInfo *thePrefs)
|
||||
PortabilityLayer::IOStream *fileStream;
|
||||
long byteCount;
|
||||
Str255 fileName;
|
||||
|
||||
|
||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||
|
||||
PasStringCopy(kPrefFileName, 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)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
theErr = FSpOpenDF(theSpecs, fsRdWrPerm, fileStream);
|
||||
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Write, fileStream);
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
@@ -98,6 +100,8 @@ PLError_t ReadPrefs (prefsInfo *thePrefs)
|
||||
long byteCount;
|
||||
VFileSpec theSpecs;
|
||||
Str255 fileName;
|
||||
|
||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||
|
||||
PasStringCopy(kPrefFileName, fileName);
|
||||
|
||||
@@ -106,7 +110,7 @@ PLError_t ReadPrefs (prefsInfo *thePrefs)
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
||||
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)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
@@ -139,12 +143,7 @@ Boolean DeletePrefs ()
|
||||
|
||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||
|
||||
theErr = FSpDelete(theSpecs);
|
||||
|
||||
if (theErr != PLErrors::kNone)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
return PortabilityLayer::FileManager::GetInstance()->DeleteFile(theSpecs.m_dir, theSpecs.m_name);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LoadPrefs
|
||||
|
@@ -7,7 +7,7 @@ static volatile uint64_t gs_prioritiesBlob = 0;
|
||||
|
||||
SoundSyncState SoundSync_ReadAll()
|
||||
{
|
||||
const uint16_t priorities = gs_prioritiesBlob;
|
||||
const uint64_t priorities = gs_prioritiesBlob;
|
||||
|
||||
SoundSyncState state;
|
||||
state.priority0 = static_cast<uint16_t>((priorities >> 0) & 0xffff);
|
||||
|
Reference in New Issue
Block a user