Пример #1
0
status_t TElementsSorter::EvaluateRef(entry_ref &ref)
{
	struct stat st;
	BEntry entry;

	// Can we create a BEntry?
	if (entry.SetTo(&ref, false) != B_OK)
		return B_ERROR;

	// Can we get a BStatable?
	if (entry.GetStat(&st) != B_OK)
		return B_ERROR;

	// Is it a SymLink?
	if (S_ISLNK(st.st_mode))
		return HandleLink(ref, st);
	// How about a File?
	else if (S_ISREG(st.st_mode))
		return HandleFile(ref, st);
	// A Directory?
	else if (S_ISDIR(st.st_mode)) {
		BDirectory dir;
		if (dir.SetTo(&ref) != B_OK)
			return B_ERROR;

		if (dir.IsRootDirectory())
			return HandleVolume(ref, st, dir);
		else
			return HandleDirectory(ref, st, dir);
	}

	// No luck
	return B_ERROR;
}
Пример #2
0
status_t TQueueDialog::EvaluateRef(entry_ref &ref) 
{
	struct stat st; 
	BEntry 		entry; 
	
	// Can we create a BEntry?
	if (entry.SetTo(&ref, false) != B_OK)
	{
		ERROR("TQueueDialog::HandleRefsMessage() - BEntry SetTo() failure -\n");
		return B_ERROR; 
	}
		
	// Can we get a BStatable?
	if (entry.GetStat(&st) != B_OK) 
	{
		ERROR("TQueueDialog::HandleRefsMessage() - BEntry GetStat() failure -\n");
		return B_ERROR; 
	}
		
	// Is it a SymLink?
	if (S_ISLNK(st.st_mode)) 
		return HandleLink(ref, st);
	// How about a File?
	else if (S_ISREG(st.st_mode)) 
		return HandleFile(ref, st); 
	// A Directory?
	else if (S_ISDIR(st.st_mode)) 
	{
		BDirectory dir; 
		if (dir.SetTo(&ref) != B_OK)
		{
			return B_ERROR;
		}
			
		if (dir.IsRootDirectory()) 
			return HandleVolume(ref, st, dir); 
		else 
			return HandleDirectory(ref, st, dir); 
	} 
	
	// No luck
	return B_ERROR;
} 
Пример #3
0
status_t
PDirectory::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BDirectory *backend = (BDirectory*)fBackend;
	if (str.ICompare("IsRoot") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsRootDirectory());
	else if (str.ICompare("EntryCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountEntries());
	else
	{
		return PNode::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}
Пример #4
0
void
Model::ResetIconFrom()
{
	BModelOpener opener(this);

	if (InitCheck() != B_OK)
		return;

	// mirror the logic from FinishSettingUpType
	if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode
			|| fBaseType == kTrashNode || fBaseType == kDesktopNode)
		&& !CheckNodeIconHint(fNode)) {
		BDirectory* directory = dynamic_cast<BDirectory*>(fNode);
		if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
			fIconFrom = kTrackerSupplied;
			return;
		} else if (directory != NULL && directory->IsRootDirectory()) {
			fIconFrom = kVolume;
			return;
		}
	}
	fIconFrom = kUnknownSource;
}