OpenRFPerm

This commit is contained in:
Kelvin Sherlock 2013-06-23 22:05:57 -04:00
parent 1aebf46653
commit f6132773db
3 changed files with 50 additions and 0 deletions

View File

@ -381,6 +381,49 @@ namespace RM
uint16_t OpenRFPerm(uint16_t trap)
{
// FUNCTION OpenRFPerm (fileName: Str255; vRefNum: Integer;
// permission: SignedByte): Integer;
ResFileRefNum refNum;
FSRef ref;
uint32_t sp;
uint32_t fileName;
uint16_t vRefNum;
uint16_t permission;
OSErr error;
sp = StackFrame<8>(fileName, vRefNum, permission);
std::string sname = ToolBox::ReadPString(fileName, true);
Log("%04x OpenRFPerm(%s, %04x, %04x)\n",
trap, sname.c_str(), vRefNum, permission);
error = FSPathMakeRef( (const UInt8 *)sname.c_str(), &ref, NULL);
if (error != noErr)
{
ToolReturn<2>(sp, (uint16_t)-1);
return SetResError(error);
}
HFSUniStr255 fork = {0,{0}};
FSGetResourceForkName(&fork);
refNum = -1;
error = FSOpenResourceFile(&ref,
fork.length,
fork.unicode,
permission,
&refNum);
ToolReturn<2>(sp, (uint16_t)refNum);
return SetResError(error);
}
// todo -- move since it's not RM related.
uint16_t UnloadSeg(uint16_t trap)
{

View File

@ -24,6 +24,7 @@ namespace RM
uint16_t ResError(uint16_t trap);
uint16_t OpenResFile(uint16_t trap);
uint16_t OpenRFPerm(uint16_t trap);
uint16_t SetResLoad(uint16_t trap);

View File

@ -310,6 +310,12 @@ namespace ToolBox {
d0 = RM::CreateResFile(trap);
break;
// OpenRFPerm (fileName: Str255; vRefNum: Integer;
// permission: SignedByte): Integer;
case 0xa9c4:
d0 = RM::OpenRFPerm(trap);
break;
// UnloadSeg (routineAddr: Ptr);
case 0xa9f1:
d0 = RM::UnloadSeg(trap);