fix high-level dispatch to properly return errors.

This commit is contained in:
Kelvin Sherlock 2014-12-22 15:23:10 -05:00
parent f1566cce45
commit d8f6edd964

View File

@ -81,11 +81,10 @@ namespace OS {
{ {
char buffer[PATH_MAX + 1]; char buffer[PATH_MAX + 1];
// TODO -- FSSpecs are valid for non-existant files // FSSpecs are valid for non-existant files
// but not non-existant directories. // but not non-existant directories.
// realpath does not behave in such a manner. // realpath does not behave in such a manner.
// expand the path. Also handles relative paths. // expand the path. Also handles relative paths.
char *cp = ::fs_spec_realpath(path.c_str(), buffer); char *cp = ::fs_spec_realpath(path.c_str(), buffer);
if (!cp) if (!cp)
@ -113,8 +112,6 @@ namespace OS {
uint32_t spec; uint32_t spec;
StackFrame<14>(vRefNum, dirID, fileName, spec); StackFrame<14>(vRefNum, dirID, fileName, spec);
std::string sname = ToolBox::ReadPString(fileName, true); std::string sname = ToolBox::ReadPString(fileName, true);
@ -171,7 +168,6 @@ namespace OS {
// write the filename... // write the filename...
ToolBox::WritePString(spec + 6, leaf); ToolBox::WritePString(spec + 6, leaf);
// TODO -- return fnf if file does not exist.
return 0; return 0;
} }
@ -193,6 +189,7 @@ namespace OS {
uint32_t spec; uint32_t spec;
uint32_t finderInfo; uint32_t finderInfo;
uint16_t d0;
StackFrame<8>(spec, finderInfo); StackFrame<8>(spec, finderInfo);
@ -206,9 +203,8 @@ namespace OS {
Log(" FSpGetFInfo(%s, %08x)\n", path.c_str(), finderInfo); Log(" FSpGetFInfo(%s, %08x)\n", path.c_str(), finderInfo);
d0 = Internal::GetFinderInfo(path, memoryPointer(finderInfo), false);
Internal::GetFinderInfo(path, memoryPointer(finderInfo), false); return d0;
return 0;
} }
uint16_t FSpSetFInfo() uint16_t FSpSetFInfo()
@ -217,7 +213,7 @@ namespace OS {
uint32_t spec; uint32_t spec;
uint32_t finderInfo; uint32_t finderInfo;
uint16_t d0; uint16_t d0 = 0;
StackFrame<8>(spec, finderInfo); StackFrame<8>(spec, finderInfo);
@ -241,10 +237,16 @@ namespace OS {
uint16_t ResolveAliasFile() uint16_t ResolveAliasFile()
{ {
// FUNCTION ResolveAliasFile (VAR theSpec: FSSpec;
// resolveAliasChains: Boolean;
// VAR targetIsFolder: Boolean;
// VAR wasAliased: Boolean): OSErr;
uint32_t spec; uint32_t spec;
uint16_t resolveAliasChains; uint16_t resolveAliasChains;
uint32_t targetIsFolder; uint32_t targetIsFolder;
uint32_t wasAliased; uint32_t wasAliased;
uint16_t d0 = 0;
StackFrame<14>(spec, resolveAliasChains, targetIsFolder, wasAliased); StackFrame<14>(spec, resolveAliasChains, targetIsFolder, wasAliased);
@ -261,17 +263,16 @@ namespace OS {
int rv; int rv;
rv = ::stat(path.c_str(), &st); rv = ::stat(path.c_str(), &st);
if (rv < 0) return macos_error_from_errno(); if (rv < 0)
return macos_error_from_errno();
if (targetIsFolder) if (targetIsFolder)
{ memoryWriteWord(S_ISDIR(st.st_mode) ? 1 : 0, targetIsFolder);
memoryWriteWord(S_ISDIR(st.st_mode) ? 1 : 0, targetIsFolder);
}
// don't bother pretending a soft link is an alias. // don't bother pretending a soft link is an alias.
if (wasAliased) memoryWriteWord(0, wasAliased); if (wasAliased) memoryWriteWord(0, wasAliased);
return 0; return d0;
} }
@ -298,6 +299,7 @@ namespace OS {
*/ */
uint16_t selector; uint16_t selector;
uint16_t d0;
selector = cpuGetDReg(0) & 0xffff; selector = cpuGetDReg(0) & 0xffff;
Log("%04x HighLevelHFSDispatch(%04x)\n", trap, selector); Log("%04x HighLevelHFSDispatch(%04x)\n", trap, selector);
@ -305,22 +307,24 @@ namespace OS {
switch (selector) switch (selector)
{ {
case 0x0001: case 0x0001:
return FSMakeFSSpec(); d0 = FSMakeFSSpec();
break; break;
case 0x0007: case 0x0007:
return FSpGetFInfo(); d0 = FSpGetFInfo();
break; break;
case 0x0008: case 0x0008:
return FSpSetFInfo(); d0 = FSpSetFInfo();
break; break;
case 0x000d: case 0x000d:
return RM::FSpOpenResFile(); d0 = RM::FSpOpenResFile();
break;
case 0x000e: case 0x000e:
return RM::FSpCreateResFile(); d0 = RM::FSpCreateResFile();
break;
default: default:
fprintf(stderr, "HighLevelHFSDispatch selector %04x not yet supported\n", selector); fprintf(stderr, "HighLevelHFSDispatch selector %04x not yet supported\n", selector);
@ -328,6 +332,9 @@ namespace OS {
} }
ToolReturn<2>(-1, d0);
return d0;
} }
uint16_t HGetVol(uint16_t trap) uint16_t HGetVol(uint16_t trap)