diff --git a/toolbox/os.cpp b/toolbox/os.cpp index 6c53ffa..be80d8e 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -569,26 +569,63 @@ namespace OS uint16_t Delete(uint16_t trap) { + enum { + /* FileParam */ + _qLink = 0, + _qType = 4, + _ioTrap = 6, + _ioCmdAddr = 8, + _ioCompletion = 12, + _ioResult = 16, + _ioNamePtr = 18, + _ioVRefNum = 22, + _ioFRefNum = 24, + _ioFVersNum = 26, + _filler1 = 27, + _ioFDirIndex = 28, + _ioFlAttrib = 30, + _ioFlVersNum = 31, + _ioFlFndrInfo = 32, + _ioFlNum = 48, + _ioFlStBlk = 52, + _ioFlLgLen = 54, + _ioFlPyLen = 58, + _ioFlRStBlk = 62, + _ioFlRLgLen = 64, + _ioFlRPyLen = 68, + _ioFlCrDat = 72, + _ioFlMdDat = 76, + + // HFileParam + _ioDirID = 48, + }; + + bool htrap = trap & 0x0200; + const char *func = htrap ? "HDelete" : "Delete"; + uint32_t d0; uint32_t parm = cpuGetAReg(0); - Log("%04x Delete(%08x)\n", trap, parm); + Log("%04x %s(%08x)\n", trap, func, parm); - //uint32_t ioCompletion = memoryReadLong(parm + 12); - uint32_t namePtr = memoryReadLong(parm + 18); - - //uint16_t ioVRefNum = memoryReadWord(parm + 22); - //uint8_t ioFVersNum = memoryReadByte(parm + 26); + uint32_t namePtr = memoryReadLong(parm + _ioNamePtr); std::string sname = ToolBox::ReadPString(namePtr, true); if (!sname.length()) { - memoryWriteWord(MacOS::bdNamErr, parm + 16); + memoryWriteWord(MacOS::bdNamErr, parm + _ioResult); return MacOS::bdNamErr; } - Log(" Delete(%s)\n", sname.c_str()); + + if (htrap) + { + uint32_t ioDirID = memoryReadLong(parm + _ioDirID); + sname = FSSpecManager::ExpandPath(sname, ioDirID); + } + + Log(" %s(%s)\n", func, sname.c_str()); int ok = ::unlink(sname.c_str()); if (ok < 0) @@ -596,10 +633,12 @@ namespace OS else d0 = 0; - memoryWriteWord(d0, parm + 16); + memoryWriteWord(d0, parm + _ioResult); return d0; } + + uint16_t GetEOF(uint16_t trap) { uint32_t d0; diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index b769992..af8eb0b 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -128,7 +128,8 @@ namespace ToolBox { d0 = OS::Create(trap); break; - case 0xa009: + case 0xa009: // Delete + case 0xa209: // HDelete d0 = OS::Delete(trap); break;