mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-24 13:32:39 +00:00
fix Open/PBOpen (no iodir/fs spec stuff)
This commit is contained in:
parent
45269178b4
commit
9d46424968
@ -337,7 +337,7 @@ namespace OS
|
||||
}
|
||||
|
||||
|
||||
uint16_t Open(uint16_t trap)
|
||||
uint16_t OpenCommon(uint32_t parm, bool fsspec, bool resource)
|
||||
{
|
||||
|
||||
enum {
|
||||
@ -368,22 +368,18 @@ namespace OS
|
||||
|
||||
int fd;
|
||||
|
||||
uint32_t parm = cpuGetAReg(0);
|
||||
|
||||
|
||||
Log("%04x Open(%08x)\n", trap, parm);
|
||||
|
||||
uint32_t namePtr = memoryReadLong(parm + _ioNamePtr);
|
||||
uint32_t ioDirID = memoryReadLong(parm + _ioDirID);
|
||||
|
||||
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
|
||||
uint32_t namePtr = memoryReadLong(parm + _ioNamePtr);
|
||||
|
||||
std::string sname = ToolBox::ReadPString(namePtr, true);
|
||||
|
||||
if (fsspec)
|
||||
{
|
||||
uint32_t ioDirID = memoryReadLong(parm + _ioDirID);
|
||||
sname = FSSpecManager::ExpandPath(sname, ioDirID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
fd = Internal::FDEntry::open(sname, ioPermission, false);
|
||||
fd = Internal::FDEntry::open(sname, ioPermission, resource);
|
||||
d0 = fd < 0 ? fd : 0;
|
||||
if (fd >= 0)
|
||||
{
|
||||
@ -394,59 +390,18 @@ namespace OS
|
||||
return d0;
|
||||
}
|
||||
|
||||
uint16_t Open(uint16_t trap)
|
||||
{
|
||||
uint32_t parm = cpuGetAReg(0);
|
||||
Log("%04x Open(%08x)\n", trap, parm);
|
||||
return OpenCommon(parm, false, false);
|
||||
}
|
||||
|
||||
uint16_t OpenRF(uint16_t trap)
|
||||
{
|
||||
|
||||
enum {
|
||||
/* IOParam */
|
||||
_qLink = 0,
|
||||
_qType = 4,
|
||||
_ioTrap = 6,
|
||||
_ioCmdAddr = 8,
|
||||
_ioCompletion = 12,
|
||||
_ioResult = 16,
|
||||
_ioNamePtr = 18,
|
||||
_ioVRefNum = 22,
|
||||
_ioRefNum = 24,
|
||||
_ioVersNum = 26,
|
||||
_ioPermssn = 27,
|
||||
_ioMisc = 28,
|
||||
_ioBuffer = 32,
|
||||
_ioReqCount = 36,
|
||||
_ioActCount = 40,
|
||||
_ioPosMode = 44,
|
||||
_ioPosOffset = 46,
|
||||
|
||||
_ioDirID = 48,
|
||||
|
||||
};
|
||||
|
||||
uint32_t d0;
|
||||
|
||||
int fd;
|
||||
|
||||
uint32_t parm = cpuGetAReg(0);
|
||||
|
||||
|
||||
Log("%04x OpenRF(%08x)\n", trap, parm);
|
||||
|
||||
uint32_t namePtr = memoryReadLong(parm + _ioNamePtr);
|
||||
uint32_t ioDirID = memoryReadLong(parm + _ioDirID);
|
||||
|
||||
uint8_t ioPermission = memoryReadByte(parm + _ioPermssn);
|
||||
|
||||
std::string sname = ToolBox::ReadPString(namePtr, true);
|
||||
sname = FSSpecManager::ExpandPath(sname, ioDirID);
|
||||
|
||||
fd = Internal::FDEntry::open(sname, ioPermission, true);
|
||||
d0 = fd < 0 ? fd : 0;
|
||||
if (fd >= 0)
|
||||
{
|
||||
memoryWriteWord(fd, parm + _ioRefNum);
|
||||
}
|
||||
|
||||
memoryWriteWord(d0, parm + _ioResult);
|
||||
return d0;
|
||||
Log("%04x Open(%08x)\n", trap, parm);
|
||||
return OpenCommon(parm, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,6 +35,8 @@ namespace OS
|
||||
time_t UnixToMac(time_t);
|
||||
time_t MacToUnix(time_t);
|
||||
|
||||
uint16_t OpenCommon(uint32_t parm, bool fsspec, bool resource);
|
||||
|
||||
|
||||
#pragma mark FS Utilities
|
||||
uint16_t Close(uint16_t trap);
|
||||
|
@ -381,7 +381,7 @@ namespace OS {
|
||||
{
|
||||
Log(" PBOpenDF\n");
|
||||
// same as Open but slightly different handling of . files.
|
||||
return OS::Open(0xa000);
|
||||
return OS::OpenCommon(paramBlock, false, false);
|
||||
}
|
||||
|
||||
|
||||
@ -391,8 +391,7 @@ namespace OS {
|
||||
// that it accepts a directory ID in ioDirID.
|
||||
|
||||
Log(" PBHOpenDF\n");
|
||||
// same as Open but slightly different handling of . files.
|
||||
return OS::Open(0xa000);
|
||||
return OS::OpenCommon(paramBlock, true, false);
|
||||
}
|
||||
|
||||
|
||||
@ -402,13 +401,13 @@ namespace OS {
|
||||
// up with the permission byte considering it's big-endian.
|
||||
|
||||
Log(" PBHOpenDeny\n");
|
||||
return OS::Open(0xa000);
|
||||
return OS::OpenCommon(paramBlock, true, false);
|
||||
}
|
||||
|
||||
uint16_t PBHOpenRFDeny(uint32_t paramBlock)
|
||||
{
|
||||
Log(" PBHOpenRFDeny\n");
|
||||
return OS::OpenRF(0xa000);
|
||||
return OS::OpenCommon(paramBlock, true, true);
|
||||
}
|
||||
|
||||
uint16_t FSDispatch(uint16_t trap)
|
||||
|
@ -448,45 +448,9 @@ namespace OS {
|
||||
|
||||
uint16_t HOpen(uint16_t trap)
|
||||
{
|
||||
|
||||
int fd;
|
||||
int d0;
|
||||
|
||||
|
||||
uint32_t parm = cpuGetAReg(0);
|
||||
|
||||
Log("%04x HOpen(%08x)\n", trap, parm);
|
||||
|
||||
uint32_t ioNamePtr = memoryReadLong(parm + 18);
|
||||
uint8_t ioPermission = memoryReadByte(parm + 27);
|
||||
uint32_t ioDirID = memoryReadLong(parm + 48);
|
||||
|
||||
std::string sname = ToolBox::ReadPString(ioNamePtr, true);
|
||||
bool absolute = sname.length() ? sname[0] == '/' : 0;
|
||||
|
||||
if (ioDirID && !absolute)
|
||||
{
|
||||
std::string dir = FSSpecManager::PathForID(ioDirID);
|
||||
if (dir.empty())
|
||||
{
|
||||
d0 = MacOS::dirNFErr;
|
||||
memoryWriteWord(d0, parm + 16);
|
||||
|
||||
return d0;
|
||||
}
|
||||
sname = dir + sname;
|
||||
}
|
||||
|
||||
fd = Internal::FDEntry::open(sname, ioPermission, false);
|
||||
|
||||
d0 = fd < 0 ? fd : 0;
|
||||
if (fd >= 0)
|
||||
{
|
||||
memoryWriteWord(fd, parm + 24);
|
||||
}
|
||||
|
||||
memoryWriteWord(d0, parm + 16);
|
||||
return d0;
|
||||
return OpenCommon(parm, true, false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user