OS::Delete

This commit is contained in:
Kelvin Sherlock 2013-02-13 22:38:34 -05:00
parent a16cd348e9
commit 5708edd11d
3 changed files with 40 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;