diff --git a/GpApp/AppleEvents.cpp b/GpApp/AppleEvents.cpp index dbf85e1..a826508 100644 --- a/GpApp/AppleEvents.cpp +++ b/GpApp/AppleEvents.cpp @@ -52,7 +52,7 @@ PLError_t DoOpenDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref) VFileInfo finderInfo; AEDescList docList; long itemsInList; - Size actualSize; + size_t actualSize; AEKeyword keywd; DescType returnedType; PLError_t theErr, whoCares; @@ -162,7 +162,7 @@ PLError_t DoQuitAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref) PLError_t MyGotRequiredParams (const AppleEvent *theAE) { DescType returnedType; - Size actualSize; + size_t actualSize; return (AEGetAttributePtr(theAE, keyMissedKeywordAttr, typeWildCard, &returnedType, 0L, 0, &actualSize) == errAEDescNotFound) ? PLErrors::kNone : diff --git a/GpApp/House.cpp b/GpApp/House.cpp index bc3dc04..7358dc2 100644 --- a/GpApp/House.cpp +++ b/GpApp/House.cpp @@ -58,7 +58,7 @@ Boolean CreateNewHouse (void) { AEKeyword theKeyword; DescType actualType; - Size actualSize; + size_t actualSize; VFileSpec tempSpec; VFileSpec theSpec; PLError_t theErr; diff --git a/GpApp/SavedGames.cpp b/GpApp/SavedGames.cpp index add4da7..936a03c 100644 --- a/GpApp/SavedGames.cpp +++ b/GpApp/SavedGames.cpp @@ -42,7 +42,7 @@ void SaveGame2 (void) PortabilityLayer::InputManager::GetInstance()->ClearState(); Str255 gameNameStr; - Size byteCount; + size_t byteCount; houseType *thisHousePtr; roomType *srcRoom; savedRoom *destRoom; diff --git a/PortabilityLayer/CFileStream.cpp b/PortabilityLayer/CFileStream.cpp index e7fae06..7c3bb6d 100644 --- a/PortabilityLayer/CFileStream.cpp +++ b/PortabilityLayer/CFileStream.cpp @@ -1,117 +1,117 @@ -#include "CFileStream.h" - -namespace PortabilityLayer -{ - CFileStream::CFileStream(FILE *f) - : m_file(f) - , m_readOnly(false) - , m_writeOnly(false) - , m_seekable(true) - { - } - - CFileStream::CFileStream(FILE *f, bool isReadOnly, bool isWriteOnly, bool isSeekable) - : m_file(f) - , m_readOnly(isReadOnly) - , m_writeOnly(isWriteOnly) - , m_seekable(isSeekable) - { - } - - size_t CFileStream::Read(void *bytesOut, size_t size) - { - if (!m_file || m_writeOnly) - return 0; - - return fread(bytesOut, 1, size, m_file); - } - - size_t CFileStream::Write(const void *bytes, size_t size) - { - if (!m_file || m_readOnly) - return 0; - - return fwrite(bytes, 1, size, m_file); - } - - bool CFileStream::IsSeekable() const - { - return m_seekable; - } - - bool CFileStream::IsReadOnly() const - { - return m_readOnly; - } - - bool CFileStream::IsWriteOnly() const - { - return m_writeOnly; - } - - bool CFileStream::SeekStart(UFilePos_t loc) - { - if (!m_file) - return false; - - return fseek(m_file, static_cast(loc), SEEK_SET) == 0; - } - - bool CFileStream::SeekCurrent(FilePos_t loc) - { - if (!m_file) - return false; - - return fseek(m_file, static_cast(loc), SEEK_CUR) == 0;; - } - - bool CFileStream::SeekEnd(UFilePos_t loc) - { - if (!m_file) - return false; - - return fseek(m_file, static_cast(loc), SEEK_END) == 0; - } - - bool CFileStream::Truncate(UFilePos_t loc) - { - return false; - } - - UFilePos_t CFileStream::Tell() const - { - if (!m_file) - return 0; - - return static_cast(ftell(m_file)); - } - - void CFileStream::Close() - { - if (m_file) - { - fclose(m_file); - m_file = nullptr; - } +#include "CFileStream.h" + +namespace PortabilityLayer +{ + CFileStream::CFileStream(FILE *f) + : m_file(f) + , m_readOnly(false) + , m_writeOnly(false) + , m_seekable(true) + { + } + + CFileStream::CFileStream(FILE *f, bool isReadOnly, bool isWriteOnly, bool isSeekable) + : m_file(f) + , m_readOnly(isReadOnly) + , m_writeOnly(isWriteOnly) + , m_seekable(isSeekable) + { + } + + size_t CFileStream::Read(void *bytesOut, size_t size) + { + if (!m_file || m_writeOnly) + return 0; + + return fread(bytesOut, 1, size, m_file); + } + + size_t CFileStream::Write(const void *bytes, size_t size) + { + if (!m_file || m_readOnly) + return 0; + + return fwrite(bytes, 1, size, m_file); + } + + bool CFileStream::IsSeekable() const + { + return m_seekable; + } + + bool CFileStream::IsReadOnly() const + { + return m_readOnly; + } + + bool CFileStream::IsWriteOnly() const + { + return m_writeOnly; + } + + bool CFileStream::SeekStart(UFilePos_t loc) + { + if (!m_file) + return false; + + return fseek(m_file, static_cast(loc), SEEK_SET) == 0; + } + + bool CFileStream::SeekCurrent(FilePos_t loc) + { + if (!m_file) + return false; + + return fseek(m_file, static_cast(loc), SEEK_CUR) == 0;; + } + + bool CFileStream::SeekEnd(UFilePos_t loc) + { + if (!m_file) + return false; + + return fseek(m_file, static_cast(loc), SEEK_END) == 0; + } + + bool CFileStream::Truncate(UFilePos_t loc) + { + return false; + } + + UFilePos_t CFileStream::Tell() const + { + if (!m_file) + return 0; + + return static_cast(ftell(m_file)); + } + + void CFileStream::Close() + { + if (m_file) + { + fclose(m_file); + m_file = nullptr; + } } void CFileStream::Flush() - { + { if (m_file) - fflush(m_file); - } - - - UFilePos_t CFileStream::Size() const - { - if (!m_file || !m_seekable) - return 0; - - long oldPos = ftell(m_file); - fseek(m_file, 0, SEEK_END); - const UFilePos_t endPos = static_cast(ftell(m_file)); - fseek(m_file, oldPos, SEEK_SET); - - return endPos; - } -} + fflush(m_file); + } + + + UFilePos_t CFileStream::Size() const + { + if (!m_file || !m_seekable) + return 0; + + long oldPos = ftell(m_file); + fseek(m_file, 0, SEEK_END); + const UFilePos_t endPos = static_cast(ftell(m_file)); + fseek(m_file, oldPos, SEEK_SET); + + return endPos; + } +} diff --git a/PortabilityLayer/CFileStream.h b/PortabilityLayer/CFileStream.h index 2ee6386..1d44d19 100644 --- a/PortabilityLayer/CFileStream.h +++ b/PortabilityLayer/CFileStream.h @@ -1,43 +1,43 @@ -#pragma once - -#ifndef __PL_CFILESTREAM_H__ -#define __PL_CFILESTREAM_H__ - -#include - -#include "CoreDefs.h" -#include "IOStream.h" - -namespace PortabilityLayer -{ - class CFileStream final : public IOStream - { - public: - explicit CFileStream(FILE *f); - CFileStream(FILE *f, bool isReadOnly, bool isWriteOnly, bool isSeekable); - - size_t Read(void *bytesOut, size_t size) override; - size_t Write(const void *bytes, size_t size) override; - bool IsSeekable() const override; - bool IsReadOnly() const override; - bool IsWriteOnly() const override; - bool SeekStart(UFilePos_t loc) override; - bool SeekCurrent(FilePos_t loc) override; - bool SeekEnd(UFilePos_t loc) override; - bool Truncate(UFilePos_t loc) override; - UFilePos_t Size() const override; - UFilePos_t Tell() const override; +#pragma once + +#ifndef __PL_CFILESTREAM_H__ +#define __PL_CFILESTREAM_H__ + +#include + +#include "CoreDefs.h" +#include "IOStream.h" + +namespace PortabilityLayer +{ + class CFileStream final : public IOStream + { + public: + explicit CFileStream(FILE *f); + CFileStream(FILE *f, bool isReadOnly, bool isWriteOnly, bool isSeekable); + + size_t Read(void *bytesOut, size_t size) override; + size_t Write(const void *bytes, size_t size) override; + bool IsSeekable() const override; + bool IsReadOnly() const override; + bool IsWriteOnly() const override; + bool SeekStart(UFilePos_t loc) override; + bool SeekCurrent(FilePos_t loc) override; + bool SeekEnd(UFilePos_t loc) override; + bool Truncate(UFilePos_t loc) override; + UFilePos_t Size() const override; + UFilePos_t Tell() const override; void Close() override; - void Flush() override; - - private: - CFileStream(const CFileStream &other) GP_DELETED; - - FILE *m_file; - bool m_readOnly; - bool m_writeOnly; - bool m_seekable; - }; -} - -#endif + void Flush() override; + + private: + CFileStream(const CFileStream &other) GP_DELETED; + + FILE *m_file; + bool m_readOnly; + bool m_writeOnly; + bool m_seekable; + }; +} + +#endif diff --git a/PortabilityLayer/PLAppleEvents.cpp b/PortabilityLayer/PLAppleEvents.cpp index 26f35bd..fd2897e 100644 --- a/PortabilityLayer/PLAppleEvents.cpp +++ b/PortabilityLayer/PLAppleEvents.cpp @@ -19,13 +19,13 @@ PLError_t AECountItems(AEDescList *descList, long *count) return PLErrors::kNone; } -PLError_t 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_t maxSize, size_t *actualSize) { PL_NotYetImplemented(); return PLErrors::kNone; } -PLError_t 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_t maxSize, size_t *actualSize) { PL_NotYetImplemented(); return PLErrors::kNone; diff --git a/PortabilityLayer/PLAppleEvents.h b/PortabilityLayer/PLAppleEvents.h index 1b73be5..1268abb 100644 --- a/PortabilityLayer/PLAppleEvents.h +++ b/PortabilityLayer/PLAppleEvents.h @@ -22,8 +22,8 @@ typedef AEEventHandler AEEventHandlerUPP; 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 AEGetNthPtr(AEDescList *descList, long index, DescType desiredType, AEKeyword *keyword, DescType *type, void *data, size_t maxSize, size_t *actualSize); +PLError_t AEGetAttributePtr(const AppleEvent *evt, AEKeyword keyword, DescType desiredType, DescType *type, void *data, size_t maxSize, size_t *actualSize); PLError_t AEInstallEventHandler(AEEventClass eventClass, AEEventID eventID, AEEventHandlerUPP handler, UInt32 ref, bool isSysHandler); PLError_t AESetInteractionAllowed(AEInteractAllowed level); diff --git a/PortabilityLayer/PLCore.cpp b/PortabilityLayer/PLCore.cpp index 7c8c574..ce8bc61 100644 --- a/PortabilityLayer/PLCore.cpp +++ b/PortabilityLayer/PLCore.cpp @@ -561,7 +561,7 @@ void ExitToShell() PL_NotYetImplemented(); } -Handle NewHandle(Size size) +Handle NewHandle(size_t size) { PortabilityLayer::MMHandleBlock *hBlock = PortabilityLayer::MemoryManager::GetInstance()->AllocHandle(size); if (!hBlock) @@ -578,7 +578,7 @@ long GetHandleSize(Handle handle) return handle.MMBlock()->m_size; } -PLError_t SetHandleSize(Handle hdl, Size newSize) +PLError_t SetHandleSize(Handle hdl, size_t newSize) { PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance(); if (!mm->ResizeHandle(hdl.MMBlock(), newSize)) @@ -587,12 +587,12 @@ PLError_t SetHandleSize(Handle hdl, Size newSize) return PLErrors::kNone; } -void *NewPtr(Size size) +void *NewPtr(size_t size) { return PortabilityLayer::MemoryManager::GetInstance()->Alloc(size); } -void *NewPtrClear(Size size) +void *NewPtrClear(size_t size) { void *data = NewPtr(size); if (data != nullptr && size != 0) diff --git a/PortabilityLayer/PLCore.h b/PortabilityLayer/PLCore.h index 0ba4f3d..49a3449 100644 --- a/PortabilityLayer/PLCore.h +++ b/PortabilityLayer/PLCore.h @@ -36,8 +36,6 @@ typedef int16_t SInt16; typedef int32_t Int32; typedef uint32_t UInt32; -typedef size_t Size; - typedef unsigned char Str15[16]; typedef unsigned char Str31[32]; typedef unsigned char Str63[64]; @@ -256,13 +254,13 @@ void GetTime(DateTimeRec *dateTime); void FlushEvents(); -Handle NewHandle(Size size); +Handle NewHandle(size_t size); long GetHandleSize(Handle handle); -PLError_t SetHandleSize(Handle hdl, Size newSize); +PLError_t SetHandleSize(Handle hdl, size_t newSize); -void *NewPtr(Size size); -void *NewPtrClear(Size size); +void *NewPtr(size_t size); +void *NewPtrClear(size_t size); void DisposePtr(void *ptr);