+ }
+ if (firstLink) {
+ /* read header */
+ if (!ensureBufferCapacity(4)) {
+ return NULL;
+ }
+ uint32_t headerTagCount = 0;
+ growingBuffer.read(&headerTagCount, 4);
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] will read %d header tags.\n", __FILE__, __LINE__, headerTagCount);
+ for (uint32_t headerTagIndex = 0; headerTagIndex < headerTagCount; headerTagIndex++) {
+ uint8_t tagType = 0;
+ if (!ensureBufferCapacity(1)) {
+ return NULL;
+ }
+ growingBuffer.read(&tagType, 1);
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] read tag type %d.\n", __FILE__, __LINE__, tagType);
+ if (tagType == 0x02) {
+ StringTag* stringTag = readStringTag(true);
+ if (stringTag->getId() == 0x01) {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] FT_FILENAME: “%s”\n", __FILE__, __LINE__, (char*) stringTag->getValue());
+ } else if (stringTag->getId() == 0x31) {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] FT_COLLECTIONAUTHOR: “%s”\n", __FILE__, __LINE__, (char*) stringTag->getValue());
+ } else {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] unknown string in header: “%s”\n", __FILE__, __LINE__, (char*) stringTag->getValue());
+ }
+ } else if (tagType == 0x07) {
+ BlobTag* blobTag = readBlobTag(true);
+ if (blobTag->getId() == 0x32) {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] FT_COLLECTIONAUTHORKEY: %d bytes.\n", __FILE__, __LINE__, blobTag->getSize());
+ } else {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] unknown block in header: %d bytes.\n", __FILE__, __LINE__, blobTag->getSize());
+ }
+ } else {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] unknown tag type: %02x.\n", __FILE__, __LINE__, tagType);
+ }
+ }
+ fileCollectionCount = 0;
+ if (!ensureBufferCapacity(4)) {
+ return NULL;
+ }
+ growingBuffer.read(&fileCollectionCount, 4);
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] will read %d file tags.\n", __FILE__, __LINE__, fileCollectionCount);
+ collectionFileIndex = 0;
+ firstLink = false;
+ }
+ if (collectionFileIndex < fileCollectionCount) {