From e88f379eb1e5ff00fef58a5859ef5e6f0f2f2c29 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 16 Feb 2013 13:33:09 -0500 Subject: [PATCH] open - set binary flag based on extension --- mpw/mpw.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mpw/mpw.cpp b/mpw/mpw.cpp index e6370e5..4ebcdb8 100644 --- a/mpw/mpw.cpp +++ b/mpw/mpw.cpp @@ -118,6 +118,8 @@ namespace { fprintf(stderr, " open(%s, %04x)\n", sname.c_str(), f.flags); + // TODO -- can you create a resource file like this? + if (f.flags & kO_RSRC) sname.append(_PATH_RSRCFORKSPEC); @@ -143,8 +145,20 @@ namespace { FDTable.resize(fd + 1); FDTable[fd] = 1; + + + // adjust the binary flags... + // most apps are good about this but dumpobj doesn't set O_BINARY (but should) + // and MPW Assembler sets O_BINARY (but shouldn't) + + if (OS::IsTextFile(sname)) f.flags &= ~kO_BINARY; + if (OS::IsBinaryFile(sname)) f.flags |= kO_BINARY; + + if (f.flags & kO_RSRC) f.flags |= kO_BINARY; + } + memoryWriteWord(f.flags, parm + 0); memoryWriteWord(f.error, parm + 2); memoryWriteLong(f.cookie, parm + 8);