From 45fae53ef597388bf69dce207cc25bccfd65f4ab Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 24 Dec 2014 10:17:23 -0500 Subject: [PATCH] fix CloseResFile with refNum 0. --- toolbox/rm.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/toolbox/rm.cpp b/toolbox/rm.cpp index 0ecfe7f..25a1289 100644 --- a/toolbox/rm.cpp +++ b/toolbox/rm.cpp @@ -196,14 +196,21 @@ namespace RM uint16_t CloseResFile(uint16_t trap) { + // PROCEDURE CloseResFile (refNum: Integer); uint16_t refNum; StackFrame<2>(refNum); Log("%04x CloseResFile(%04x)\n", trap, refNum); - ::CloseResFile(refNum); - return SetResError(::ResError()); + + // If the value of the refNum parameter is 0, it represents the System file and is ignored. + if (refNum != 0) + { + ::CloseResFile(refNum); + return SetResError(::ResError()); + } + return SetResError(0); //return SetResError(resFNotFound); } @@ -543,7 +550,8 @@ namespace RM buffer[7] = creator >> 0; std::memcpy(buffer+4, &creator, 4); - OS::Internal::SetFinderInfo(sname, buffer, false); + // this is a new file, set the full finder info. + OS::Internal::SetFinderInfo(sname, buffer, true); } return SetResError(rv.error() == errFSForkExists ? 0 : rv.error());