TEXT file type is a text file

This commit is contained in:
Kelvin Sherlock 2013-07-19 19:58:07 -04:00
parent 7c127931e1
commit 541ac7fc29
1 changed files with 11 additions and 0 deletions

View File

@ -96,6 +96,17 @@ namespace OS
// known text file extensions
bool IsTextFile(const std::string &s)
{
// 1. check for a TEXT file type.
{
int rv;
char buffer[32];
rv = ::getxattr(s.c_str(), XATTR_FINDERINFO_NAME, buffer, 32, 0, 0);
if (rv >= 8 && memcmp(buffer, "TEXT", 4) == 0)
return true;
}
std::string ext = extension(s);
if (ext.empty()) return false;