- if (state->cbs_hfsPlus) {
- switch(crp->recordType) {
- case kHFSPlusFolderRecord:
- catent.d_type = DT_DIR;
- catent.d_fileno = crp->hfsPlusFolder.folderID;
- break;
- case kHFSPlusFileRecord:
- catent.d_type = DT_REG;
- catent.d_fileno = crp->hfsPlusFile.fileID;
- break;
- default:
- return (0); /* stop */
- };
-
- cnp = (CatalogName*) &ckp->hfsPlus.nodeName;
- result = utf8_encodestr(cnp->ustr.unicode, cnp->ustr.length * sizeof(UniChar),
- catent.d_name, &utf8chars, kdirentMaxNameBytes + 1, ':', 0);
- if (result == ENAMETOOLONG) {
- result = ConvertUnicodeToUTF8Mangled(cnp->ustr.length * sizeof(UniChar),
- cnp->ustr.unicode, kdirentMaxNameBytes + 1, (ByteCount*)&utf8chars, catent.d_name, catent.d_fileno);
+ if (state->cbs_extended) {
+ entry = state->cbs_direntry;
+ nameptr = &entry->d_name[0];
+ maxnamelen = NAME_MAX;
+ } else {
+ nameptr = &catent.d_name[0];
+ maxnamelen = NAME_MAX;
+ }
+
+ if (state->cbs_extended && stop_after_pack) {
+ cnid = INT_MAX; /* the last item returns a non-zero invalid cookie */
+ } else {
+ if (!(hfsmp->hfs_flags & HFS_STANDARD)) {
+ switch(crp->recordType) {
+ case kHFSPlusFolderRecord:
+ type = DT_DIR;
+ cnid = crp->hfsPlusFolder.folderID;
+ /* Hide our private meta data directory */
+ if ((curID == kHFSRootFolderID) &&
+ (cnid == hfsmp->hfs_privdir_desc.cd_cnid)) {
+ hide = 1;
+ }
+
+ break;
+ case kHFSPlusFileRecord:
+ itime = to_bsd_time(crp->hfsPlusFile.createDate);
+ /*
+ * When a hardlink link is encountered save its link ref.
+ */
+ if ((SWAP_BE32(crp->hfsPlusFile.userInfo.fdType) == kHardLinkFileType) &&
+ (SWAP_BE32(crp->hfsPlusFile.userInfo.fdCreator) == kHFSPlusCreator) &&
+ ((itime == (time_t)hfsmp->hfs_itime) ||
+ (itime == (time_t)hfsmp->hfs_metadata_createdate))) {
+ ilinkref = crp->hfsPlusFile.bsdInfo.special.iNodeNum;
+ }
+ type = MODE_TO_DT(crp->hfsPlusFile.bsdInfo.fileMode);
+ cnid = crp->hfsPlusFile.fileID;
+ /* Hide the journal files */
+ if ((curID == kHFSRootFolderID) &&
+ ((hfsmp->jnl || ((HFSTOVCB(hfsmp)->vcbAtrb & kHFSVolumeJournaledMask) && (hfsmp->hfs_flags & HFS_READ_ONLY)))) &&
+ ((cnid == hfsmp->hfs_jnlfileid) ||
+ (cnid == hfsmp->hfs_jnlinfoblkid))) {
+ hide = 1;
+ }
+ break;
+ default:
+ return (0); /* stop */
+ };
+
+ cnp = (CatalogName*) &ckp->hfsPlus.nodeName;
+ result = utf8_encodestr(cnp->ustr.unicode, cnp->ustr.length * sizeof(UniChar),
+ nameptr, &namelen, maxnamelen + 1, ':', 0);
+ if (result == ENAMETOOLONG) {
+ result = ConvertUnicodeToUTF8Mangled(cnp->ustr.length * sizeof(UniChar),
+ cnp->ustr.unicode, maxnamelen + 1,
+ (ByteCount*)&namelen, nameptr,
+ cnid);
+ is_mangled = 1;
+ }
+ } else { /* hfs */
+ switch(crp->recordType) {
+ case kHFSFolderRecord:
+ type = DT_DIR;
+ cnid = crp->hfsFolder.folderID;
+ break;
+ case kHFSFileRecord:
+ type = DT_REG;
+ cnid = crp->hfsFile.fileID;
+ break;
+ default:
+ return (0); /* stop */
+ };
+
+ cnp = (CatalogName*) ckp->hfs.nodeName;
+ result = hfs_to_utf8(hfsmp, cnp->pstr, maxnamelen + 1,
+ (ByteCount *)&namelen, nameptr);
+ /*
+ * When an HFS name cannot be encoded with the current
+ * volume encoding we use MacRoman as a fallback.
+ */
+ if (result)
+ result = mac_roman_to_utf8(cnp->pstr, maxnamelen + 1,
+ (ByteCount *)&namelen, nameptr);