long position = streamHandler.mark();
int location = helper.getCurrentLocation();
// "dot": Current Directory
HashMap dotMemory = doDRLengthFixup(doDotDR(dir));
Fixup dotLocationFixup = (Fixup) dotMemory.get("drLocationFixup");
Fixup dotLengthFixup = (Fixup) dotMemory.get("drDataLengthFixup");
// "dotdot": Parent Directory
HashMap dotdotMemory = doDRLengthFixup(doDotDotDR(dir));
Fixup dotdotLocationFixup = (Fixup) dotdotMemory.get("drLocationFixup");
Fixup dotdotLengthFixup = (Fixup) dotdotMemory.get("drDataLengthFixup");
// Prepare files and directories to be processed in sorted order
Vector contents = new Vector();
contents.addAll(dir.getDirectories());
contents.addAll(dir.getFiles());
Collections.sort(contents);
Iterator it = contents.iterator();
while (it.hasNext()) {
doBlockCheck(position);
Object object = it.next();
if (object instanceof ISO9660Directory) {
ISO9660Directory subdir = (ISO9660Directory) object;
if (subdir.isMoved() && dir != root.getMovedDirectoriesStore()) {
doDRLengthFixup(doFakeDR(subdir));
} else {
doDRLengthFixup(doDR(subdir));
}
} else if (object instanceof ISO9660File) {
ISO9660File file = (ISO9660File) object;
doDRLengthFixup(doDR(file));
} else {
throw new HandlerException("Neither file nor directory: " + object);
}
}
streamHandler.endElement();
// Compute sector-padded length for Directory Data Length Fixups
int length = helper.getCurrentLocation() - location;
length *= ISO9660Constants.LOGICAL_BLOCK_SIZE;
// Save Location and Length to parentMapper
ParentInfo dotInfo = new ParentInfo();
dotInfo.location = location;
dotInfo.length = length;
parentMapper.put(dir, dotInfo);
// Write and close "dot" Fixups
dotLocationFixup.data(new BothWordDataReference(location));
dotLocationFixup.close();
dotLengthFixup.data(new BothWordDataReference(length));
dotLengthFixup.close();
// Retrieve Parent Location and Length from parentMapper
ParentInfo dotdotInfo = (ParentInfo) parentMapper.get(dir.getParentDirectory());
// Write and close "dotdot" Fixups
dotdotLocationFixup.data(new BothWordDataReference(dotdotInfo.location));
dotdotLocationFixup.close();
dotdotLengthFixup.data(new BothWordDataReference(dotdotInfo.length));
dotdotLengthFixup.close();
// Write and close Fixups of linking Directory Records
DirFixupPair fixups = (DirFixupPair) dirFixups.get(dir);
if (fixups != null) {
// Write and close Location Fixup
fixups.location.data(new BothWordDataReference(location));
fixups.location.close();
// Write and close Length Fixup
fixups.length.data(new BothWordDataReference(length));
fixups.length.close();
}
// Write and close Type L Path Table Fixup
Fixup typeLPTDirLocation = (Fixup) typeLPTFixups.get(dir);
typeLPTDirLocation.data(new LSBFWordDataReference(location));
typeLPTDirLocation.close();
// Write and close Type M Path Table Fixup
Fixup typeMPTDirLocation = (Fixup) typeMPTFixups.get(dir);
typeMPTDirLocation.data(new WordDataReference(location));
typeMPTDirLocation.close();
}