From 1e2c1a8f5ddc30fd42d3e959e5ba1deee0c78896 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 5 Jan 2015 13:12:06 -0500 Subject: [PATCH] FSpOpenDF --- toolbox/os_highlevel.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/toolbox/os_highlevel.cpp b/toolbox/os_highlevel.cpp index 74738b2..8506906 100644 --- a/toolbox/os_highlevel.cpp +++ b/toolbox/os_highlevel.cpp @@ -182,6 +182,34 @@ namespace OS { return 0; } + uint16_t FSpOpenDF() + { + // FUNCTION FSpOpenDF (spec: FSSpec; permission: SignedByte; VAR refNum: Integer): OSErr; + + uint32_t spec; + uint8_t permission; + uint32_t refNum; + + StackFrame<10>(spec, permission, refNum); + + int parentID = memoryReadLong(spec + 2); + std::string sname = ToolBox::ReadPString(spec + 6, false); + + Log(" FSpOpenDF(%s, %02x, %04x)\n", sname.c_str(), permission, refNum); + + sname = OS::FSSpecManager::ExpandPath(sname, parentID); + if (sname.empty()) + { + return MacOS::dirNFErr; + } + + int fd = Internal::FDEntry::open(sname, permission, 0); + if (fd < 0) return fd; + + memoryWriteWord(fd, refNum); + + return 0; + } uint16_t FSpGetFInfo() { @@ -363,6 +391,9 @@ namespace OS { case 0x0001: d0 = FSMakeFSSpec(); break; + case 0x0002: + d0 = FSpOpenDF(); + break; case 0x0004: d0 = FSpCreate();