use finder info to check binary files (linkiigs errors)

This commit is contained in:
Kelvin Sherlock 2013-03-02 17:38:51 -05:00
parent 7578fbce73
commit adba68c724
2 changed files with 34 additions and 2 deletions

View File

@ -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;

View File

@ -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;