* Copyright 2017, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Brian Hill, supernova@tycho.email
*/
#include "AppRefFilter.h"
#include <string.h>
AppRefFilter::AppRefFilter()
:
BRefFilter()
{
}
bool
AppRefFilter::Filter(const entry_ref *ref, BNode *node,
struct stat_beos *st, const char *filetype)
{
char* type = NULL;
const char *constFileType;
bool isSymlink = strcmp("application/x-vnd.Be-symlink", filetype) == 0;
if (isSymlink) {
BEntry linkedEntry(ref, true);
if (linkedEntry.InitCheck()!=B_OK)
return false;
BNode linkedNode(&linkedEntry);
if (linkedNode.InitCheck()!=B_OK)
return false;
BNodeInfo linkedNodeInfo(&linkedNode);
if (linkedNodeInfo.InitCheck()!=B_OK)
return false;
type = new char[B_ATTR_NAME_LENGTH];
if (linkedNodeInfo.GetType(type)!=B_OK) {
delete[] type;
return false;
}
constFileType = type;
} else
constFileType = filetype;
bool pass = false;
if (strcmp("application/x-vnd.Be-directory", constFileType) == 0)
pass = true;
else if (strcmp("application/x-vnd.Be-volume", constFileType) == 0)
pass = true;
else if (strcmp("application/x-vnd.Be-elfexecutable", constFileType) == 0)
pass = true;
else if (strcmp("application/x-vnd.be-elfexecutable", constFileType) == 0)
pass = true;
if (isSymlink)
delete[] type;
return pass;
}