From 5708edd11d7a42d2bab591e67005e3e7901bbc23 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 13 Feb 2013 22:38:34 -0500 Subject: [PATCH] OS::Delete --- toolbox/os.cpp | 35 +++++++++++++++++++++++++++++++++++ toolbox/os.h | 1 + toolbox/toolbox.cpp | 5 ++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/toolbox/os.cpp b/toolbox/os.cpp index 67aea3c..5b7fec3 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -24,6 +24,7 @@ namespace { { switch (xerrno) { + case 0: return 0; case EBADF: return rfNumErr; case EIO: return ioErr; case EACCES: return permErr; @@ -35,6 +36,8 @@ namespace { case EEXIST: return dupFNErr; + case EBUSY: return fBsyErr; + case EDQUOT: return dskFulErr; case ENOSPC: return dskFulErr; @@ -87,7 +90,39 @@ namespace OS memoryWriteWord(d0, parm + 16); return d0; + } + uint16_t Delete(uint16_t trap) + { + uint32_t d0; + + uint32_t parm = cpuGetAReg(0); + + fprintf(stderr, "%04x Delete(%08x)\n", trap, 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); + + std::string sname = ToolBox::ReadPString(namePtr); + + if (!sname.length()) + { + memoryWriteWord(bdNamErr, parm + 16); + return bdNamErr; + } + fprintf(stderr, " Delete(%s)\n", sname.c_str()); + + int ok = ::unlink(sname.c_str()); + if (ok < 0) + d0 = errno_to_oserr(errno); + else + d0 = 0; + + memoryWriteWord(d0, parm + 16); + return d0; } diff --git a/toolbox/os.h b/toolbox/os.h index 3e668de..0b1eb55 100644 --- a/toolbox/os.h +++ b/toolbox/os.h @@ -100,6 +100,7 @@ namespace OS uint16_t Create(uint16_t trap); + uint16_t Delete(uint16_t trap); uint16_t GetFileInfo(uint16_t trap); uint16_t SetFileInfo(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 5c29bf9..ab126fc 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -33,7 +33,10 @@ namespace ToolBox { case 0xa008: d0 = OS::Create(trap); break; - + case 0xa009: + d0 = OS::Delete(trap); + break; + case 0xA00C: d0 = OS::GetFileInfo(trap); break;