::Node* TarFS::Directory::Lookup(const char* name, bool traverseLinks) { TarFS::Entry* entry = LookupEntry(name); if (!entry) return NULL; Node* node = entry->ToNode(); if (traverseLinks) { if (S_ISLNK(node->Type())) { Symlink* symlink = static_cast<Symlink*>(node); int fd = open_from(this, symlink->LinkPath(), O_RDONLY); if (fd >= 0) { node = get_node_from(fd); close(fd); } } } if (node) node->Acquire(); return node; }
status_t TarFS::Directory::GetNextNode(void* _cookie, Node** _node) { EntryIterator* iterator = (EntryIterator*)_cookie; TarFS::Entry* entry = iterator->Next(); if (entry != NULL) { *_node = entry->ToNode(); return B_OK; } return B_ENTRY_NOT_FOUND; }
status_t TarFS::Directory::GetNextEntry(void* _cookie, char* name, size_t size) { EntryIterator* iterator = (EntryIterator*)_cookie; TarFS::Entry* entry = iterator->Next(); if (entry != NULL) { strlcpy(name, entry->Name(), size); return B_OK; } return B_ENTRY_NOT_FOUND; }
::Node* TarFS::Directory::LookupDontTraverse(const char* name) { TarFS::Entry* entry = LookupEntry(name); if (!entry) return NULL; Node* node = entry->ToNode(); if (node) node->Acquire(); return node; }
TarFS::Entry* TarFS::Directory::LookupEntry(const char* name) { EntryIterator iterator(fEntries.GetIterator()); while (iterator.HasNext()) { TarFS::Entry* entry = iterator.Next(); if (strcmp(name, entry->Name()) == 0) return entry; } return NULL; }