virtual status_t HandleEntry(BPackageEntry* entry) { if (fErrorOccurred) return B_OK; PackageDirectory* parentDir = NULL; if (entry->Parent() != NULL) { parentDir = dynamic_cast<PackageDirectory*>( (PackageNode*)entry->Parent()->UserToken()); if (parentDir == NULL) RETURN_ERROR(B_BAD_DATA); } status_t error; // get the file mode -- filter out write permissions mode_t mode = entry->Mode() & ~(mode_t)(S_IWUSR | S_IWGRP | S_IWOTH); // create the package node PackageNode* node; if (S_ISREG(mode)) { // file node = new(std::nothrow) PackageFile(fPackage, mode, entry->Data()); } else if (S_ISLNK(mode)) { // symlink PackageSymlink* symlink = new(std::nothrow) PackageSymlink( fPackage, mode); if (symlink == NULL) RETURN_ERROR(B_NO_MEMORY); error = symlink->SetSymlinkPath(entry->SymlinkPath()); if (error != B_OK) { delete symlink; return error; } node = symlink; } else if (S_ISDIR(mode)) { // directory node = new(std::nothrow) PackageDirectory(fPackage, mode); } else RETURN_ERROR(B_BAD_DATA); if (node == NULL) RETURN_ERROR(B_NO_MEMORY); BReference<PackageNode> nodeReference(node, true); error = node->Init(parentDir, entry->Name()); if (error != B_OK) RETURN_ERROR(error); node->SetModifiedTime(entry->ModifiedTime()); // add it to the parent directory if (parentDir != NULL) parentDir->AddChild(node); else fPackage->AddNode(node); entry->SetUserToken(node); return B_OK; }
virtual status_t HandleEntry(BPackageEntry* entry) { if (fErrorOccurred || (fLastSettingsEntry != NULL && fLastSettingsEntry->IsBlackListed())) { return B_OK; } PackageDirectory* parentDir = NULL; if (const BPackageEntry* parentEntry = entry->Parent()) { if (!S_ISDIR(parentEntry->Mode())) RETURN_ERROR(B_BAD_DATA); parentDir = static_cast<PackageDirectory*>( (PackageNode*)parentEntry->UserToken()); } if (fSettingsItem != NULL && (parentDir == NULL || entry->Parent() == fLastSettingsEntryEntry)) { PackageSettingsItem::Entry* settingsEntry = fSettingsItem->FindEntry(fLastSettingsEntry, entry->Name()); if (settingsEntry != NULL) { fLastSettingsEntry = settingsEntry; fLastSettingsEntryEntry = entry; if (fLastSettingsEntry->IsBlackListed()) return B_OK; } } if (parentDir == NULL) parentDir = fVolume->RootDirectory(); status_t error; // get the file mode -- filter out write permissions mode_t mode = entry->Mode() & ~(mode_t)(S_IWUSR | S_IWGRP | S_IWOTH); // create the package node PackageNode* node; if (S_ISREG(mode)) { // file node = new(std::nothrow) PackageFile(fVolume, mode, entry->Data()); } else if (S_ISLNK(mode)) { // symlink PackageSymlink* symlink = new(std::nothrow) PackageSymlink( fVolume, mode); if (symlink == NULL) RETURN_ERROR(B_NO_MEMORY); error = symlink->SetSymlinkPath(entry->SymlinkPath()); if (error != B_OK) { delete symlink; return error; } node = symlink; } else if (S_ISDIR(mode)) { // directory node = new(std::nothrow) PackageDirectory(fVolume, mode); } else RETURN_ERROR(B_BAD_DATA); if (node == NULL) RETURN_ERROR(B_NO_MEMORY); error = node->Init(parentDir, entry->Name(), fVolume->NextNodeID()); if (error != B_OK) { delete node; RETURN_ERROR(error); } node->SetModifiedTime(entry->ModifiedTime()); // add it to the parent directory parentDir->AddChild(node); entry->SetUserToken(node); return B_OK; }