mirror of
https://github.com/ksherlock/mpw.git
synced 2024-12-22 15:29:45 +00:00
use finder info to check binary files (linkiigs errors)
This commit is contained in:
parent
7578fbce73
commit
adba68c724
@ -97,8 +97,9 @@ namespace MPW
|
||||
|
||||
|
||||
// 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)
|
||||
// some apps are good about this but
|
||||
// dumpobj, makelib, linkiigs don't set O_BINARY (but should)
|
||||
// MPW Assembler sets O_BINARY (but shouldn't)
|
||||
|
||||
if (OS::IsTextFile(sname)) f.flags &= ~kO_BINARY;
|
||||
if (OS::IsBinaryFile(sname)) f.flags |= kO_BINARY;
|
||||
|
@ -174,12 +174,43 @@ namespace OS
|
||||
// known binary file extensions
|
||||
bool IsBinaryFile(const std::string &s)
|
||||
{
|
||||
|
||||
// first -- check for a finder info extension.
|
||||
{
|
||||
uint8_t buffer[32];
|
||||
int rv;
|
||||
|
||||
rv = ::getxattr(s.c_str(), XATTR_FINDERINFO_NAME, buffer, 32, 0, 0);
|
||||
|
||||
if (rv >= 8 && ::memcmp(buffer + 4, "pdos",4) == 0)
|
||||
{
|
||||
// Bx__ ?
|
||||
if (buffer[0] == 'B' && buffer[2] == ' ' && buffer[3] == ' ')
|
||||
return true;
|
||||
|
||||
// "p" $uv $wx $yz
|
||||
if (buffer[0] == 'p')
|
||||
{
|
||||
uint8_t fileType = buffer[1];
|
||||
//uint16_t auxType = buffer[2] | (buffer[3] << 8);
|
||||
|
||||
if (fileType >= 0xb1 && fileType <= 0xbf)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string ext = extension(s);
|
||||
if (ext.empty()) return false;
|
||||
|
||||
char c = ext[0];
|
||||
switch(c)
|
||||
{
|
||||
case 'l':
|
||||
if (ext == "lib")
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (ext == "o")
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user