From 457c045ebe02d17dd4f71fd02d29ca7042897d3f Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 30 Jun 2013 13:08:26 -0400 Subject: [PATCH] RM::GetResourceSizeOnDisk --- toolbox/rm.cpp | 27 +++++++++++++++++++++++++++ toolbox/rm.h | 1 + toolbox/toolbox.cpp | 5 ++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/toolbox/rm.cpp b/toolbox/rm.cpp index eff49ce..18da9bb 100644 --- a/toolbox/rm.cpp +++ b/toolbox/rm.cpp @@ -755,6 +755,33 @@ namespace RM return SetResError(::ResError()); } + uint16_t GetResourceSizeOnDisk(uint16_t trap) + { + // FUNCTION GetResourceSizeOnDisk (theResource: Handle): LongInt; + + uint32_t sp; + uint32_t theResource; + + sp = StackFrame<4>(theResource); + + Log("%04x GetResourceSizeOnDisk(%08x)\n", trap, theResource); + + + auto iter = rhandle_map.find(theResource); + if (iter == rhandle_map.end()) + { + ToolReturn<4>(sp, (uint32_t)0); + return SetResError(MacOS::resNotFound); + } + + Handle nativeHandle = iter->second; + uint32_t size = ::GetResourceSizeOnDisk(nativeHandle); + + ToolReturn<4>(sp, size); + return SetResError(::ResError()); + } + + // todo -- move since it's not RM related. diff --git a/toolbox/rm.h b/toolbox/rm.h index c048045..ad62aab 100644 --- a/toolbox/rm.h +++ b/toolbox/rm.h @@ -47,6 +47,7 @@ namespace RM uint16_t RemoveResource(uint16_t trap); + uint16_t GetResourceSizeOnDisk(uint16_t trap); } diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index b8ed785..d1306b2 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -335,7 +335,10 @@ namespace ToolBox { d0 = RM::ReleaseResource(trap); break; - + case 0xa9a5: + d0 = RM::GetResourceSizeOnDisk(trap); + break; + case 0xa9a6: d0 = RM::GetResAttrs(trap); break;