for (ResourceIterator i = getResources(); i.hasNext();) {
ArchiveEntry entry = i.next();
switch (entry.getType()) {
case ArchiveEntry.DIRECTORY: {
ISO9660Directory dir;
dir = new ISO9660Directory(getName(entry));
directories.put(getPath(entry), dir);
String path = getPath(entry);
while ((path = getParentPath(path)) != "") {
dir = new ISO9660Directory(getName(path));
directories.put(path, dir);
}
break;
}
case ArchiveEntry.FILE: {
ISO9660File file;
ISO9660Directory dir;
/* Create the file */
file = new ISO9660File(
new ArchiveEntryDataReference(entry),
getName(entry), entry.getResource()
.getLastModified());
files.put(getPath(entry), file);
String path = getPath(entry);
while ((path = getParentPath(path)) != "") {
dir = new ISO9660Directory(getName(path));
directories.put(path, dir);
}
break;
}
default:
throw new Iso9660ArchiverException(
Type.UnsupportedEntryType, "Unknown entry type");
}
}
/* Attache children to their parents */
for (Map.Entry<String, ISO9660Directory> e : directories.entrySet()) {
if (!e.getKey().equals("")) {
ISO9660Directory parent = directories.get(getParentPath(e
.getKey()));
parent.addDirectory(e.getValue());
}
}
for (Map.Entry<String, ISO9660File> e : files.entrySet()) {
ISO9660Directory parent = directories.get(getParentPath(e
.getKey()));
parent.addFile(e.getValue());
}
StreamHandler streamHandler = new ISOImageFileHandler(new File(
dest.getParentFile(), dest.getName()));
CreateISO iso = new CreateISO(streamHandler, root);