JBoolean JDirInfo::IsVisible ( const JDirEntry& entry ) const { const JDirEntry::Type type = entry.GetType(); const JString& name = entry.GetName(); if (!itsShowHiddenFlag && name.GetFirstCharacter() == '.' && name != "..") { return kJFalse; } if (!itsShowVCSDirsFlag && JIsVCSDirectory(name)) { return kJFalse; } if (type == JDirEntry::kDir || type == JDirEntry::kDirLink) { return JI2B(itsShowDirsFlag && (!itsFilterDirsFlag || MatchesNameFilter(entry)) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kFile || type == JDirEntry::kFileLink || type == JDirEntry::kBrokenLink) { return JI2B(itsShowFilesFlag && MatchesNameFilter(entry) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kUnknown || type == JDirEntry::kUnknownLink) { return JI2B(itsShowOthersFlag && MatchesNameFilter(entry) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kDoesNotExist) { return kJFalse; } else { assert( 0 ); // this should never happen return kJFalse; } }
GPMProcessEntry::GPMProcessEntry ( JTree* tree, const JDirEntry& entry ) : JNamedTreeNode(tree, "", kJFalse), itsLastUTime(0), itsLastSTime(0) { itsProcPath = entry.GetFullName(); itsUID = entry.GetUserID(); itsUser = entry.GetUserName(); JUInt value; entry.GetName().ConvertToUInt(&value); itsPID = value; }
JBoolean JDirInfo::MatchesNameFilter ( const JDirEntry& entry ) const { if (itsNameRegex != NULL) { const JString& name = entry.GetName(); JBoolean match = itsNameRegex->Match(name); if (itsInvertNameRegexFlag) { match = !match; } return match; } else { return kJTrue; } }
void GAddressBookMgr::AddAddressBook ( const JCharacter* name, JTree* tree ) { if (!JFileExists(name)) { return; } JDirEntry* dirEntry = new JDirEntry(name); assert(dirEntry != NULL); JTreeNode* jbase = tree->GetRoot(); JNamedTreeNode* base = dynamic_cast<JNamedTreeNode*>(jbase); assert(base != NULL); GAddressBookTreeNode* book = new GAddressBookTreeNode(dirEntry, base, dirEntry->GetName()); assert(book != NULL); std::ifstream is(name); while (is.good()) { JString line = JReadLine(is); GAddressBookEntry* entry = new GAddressBookEntry(); assert( entry != NULL ); JString name; if (GetNextRecord(line, name, is)) { GetNextRecord(line, entry->fullname, is); if (GetNextRecord(line, entry->address, is)) { GetNextRecord(line, entry->fcc, is); GetNextRecord(line, entry->comment, is); itsAddresses->SetElement(name, entry, JPtrArrayT::kDelete); GAddressEntryTreeNode* aEntry = new GAddressEntryTreeNode(book, entry->fullname); assert(aEntry != NULL); GAddressItemTreeNode* item = new GAddressItemTreeNode(GAddressItemTreeNode::kName, aEntry, name, kJFalse); assert(item != NULL); JString address = entry->address; if (address.BeginsWith("(") && address.GetLength() > 2) { address = address.GetSubstring(2, address.GetLength() - 1); JPtrArray<JString> list(JPtrArrayT::kForgetAll); GParseNameList(address, list); const JSize count = list.GetElementCount(); for (JSize i = count; i >= 1; i--) { item = new GAddressItemTreeNode(GAddressItemTreeNode::kEMail, aEntry, *(list.NthElement(i)), kJFalse); assert(item != NULL); } list.DeleteAll(); } else { item = new GAddressItemTreeNode(GAddressItemTreeNode::kEMail, aEntry, address, kJFalse); } if (!entry->comment.IsEmpty()) { item = new GAddressItemTreeNode(GAddressItemTreeNode::kComment, aEntry, entry->comment, kJFalse); assert(item != NULL); } if (!entry->fcc.IsEmpty()) { item = new GAddressItemTreeNode(GAddressItemTreeNode::kFcc, aEntry, entry->fcc, kJFalse); assert(item != NULL); } book->InsertSorted(aEntry); continue; } } delete entry; } }