From c7ccb62e6cad203fe425e1cdc0e4a67dfbd09749 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 16 Feb 2013 16:11:10 -0500 Subject: [PATCH] OS::GetEOF --- toolbox/os.cpp | 32 ++++++++++++++++++++++++++++++++ toolbox/os.h | 1 + toolbox/toolbox.cpp | 5 +++++ 3 files changed, 38 insertions(+) diff --git a/toolbox/os.cpp b/toolbox/os.cpp index 541ed3f..285c552 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -207,6 +207,38 @@ namespace OS return d0; } + uint16_t GetEOF(uint16_t trap) + { + uint32_t d0; + size_t size; + + uint32_t parm = cpuGetAReg(0); + + fprintf(stderr, "%04x GetEOF(%08x)\n", trap, parm); + + uint32_t ioCompletion = memoryReadLong(parm + 12); + uint16_t ioRefNum = memoryReadWord(parm + 24); + + struct stat st; + + if (::fstat(ioRefNum, &st) < 0) + { + d0 = errno_to_oserr(errno); + size = 0; + } + else + { + d0 = 0; + size = st.st_size; + } + + memoryWriteWord(d0, parm + 16); + memoryWriteLong(size, parm + 28); + + return d0; + } + + // return the name of the default volume. // this does not translate well. diff --git a/toolbox/os.h b/toolbox/os.h index 45e1931..a04f494 100644 --- a/toolbox/os.h +++ b/toolbox/os.h @@ -110,6 +110,7 @@ namespace OS uint16_t GetFileInfo(uint16_t trap); uint16_t SetFileInfo(uint16_t trap); + uint16_t GetEOF(uint16_t trap); uint16_t GetVol(uint16_t trap); } diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 435e4a3..04d3cc3 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -41,10 +41,15 @@ namespace ToolBox { case 0xA00C: d0 = OS::GetFileInfo(trap); break; + case 0xa00d: d0 = OS::SetFileInfo(trap); break; + case 0xa011: + d0 = OS::GetEOF(trap); + break; + case 0xa014: d0 = OS::GetVol(trap); break;