Package com.github.stephenc.javaisotools.sabre

Examples of com.github.stephenc.javaisotools.sabre.Fixup


    public void endDocument() throws HandlerException {
        // Write and close Empty File Fixups
        factory.doEmptyFileFixups();

        // Write and close Volume Space Size Fixup
        Fixup volumeSpaceSizeFixup = (Fixup) volumeFixups.get("volumeSpaceSizeFixup");
        volumeSpaceSizeFixup.data(new BothWordDataReference(helper.getCurrentLocation()));
        volumeSpaceSizeFixup.close();
        volumeFixups.remove("volumeSpaceSizeFixup");

        super.endDocument();
    }
View Full Code Here


    public HashMap doCEEntry() throws HandlerException {
        HashMap memory = new HashMap();
        streamHandler.startElement(new SystemUseEntryElement("CE", 1));

        Fixup ceLocationFixup = streamHandler.fixup(new BothWordDataReference(0));
        memory.put("ceLocationFixup", ceLocationFixup);

        Fixup ceOffsetFixup = streamHandler.fixup(new BothWordDataReference(0));
        memory.put("ceOffsetFixup", ceOffsetFixup);

        Fixup ceLengthFixup = streamHandler.fixup(new BothWordDataReference(0));
        memory.put("ceLengthFixup", ceLengthFixup);

        streamHandler.endElement();
        return memory;
    }
View Full Code Here

        HashMap ptFixups;
        long position = streamHandler.mark();
        int location = helper.getCurrentLocation();
        if (type == ISO9660Constants.TYPE_L_PT) {
            ptFixups = typeLPTFixups;
            Fixup ptLocationFixup = (Fixup) volumeFixups.get("typeLPTLocationFixup");
            ptLocationFixup.data(new LSBFWordDataReference(location));
            ptLocationFixup.close();
            volumeFixups.remove("typeLPTLocationFixup");
        } else if (type == ISO9660Constants.TYPE_M_PT) {
            ptFixups = typeMPTFixups;
            Fixup ptLocationFixup = (Fixup) volumeFixups.get("typeMPTLocationFixup");
            ptLocationFixup.data(new WordDataReference(location));
            ptLocationFixup.close();
            volumeFixups.remove("typeMPTLocationFixup");
        } else {
            throw new HandlerException("Unknown Path Table Type: " + type);
        }

        HashMap parentMapper = new HashMap();
        ISO9660Directory dir = root;
        int dirNumber = 1;

        // Root Directory
        ISO9660PathTableRecord rptr = new ISO9660PathTableRecord(streamHandler, type, ISO9660Constants.FI_ROOT, 1);
        ptFixups.put(root, rptr.doPTR());
        parentMapper.put(dir, new Integer(dirNumber));

        // Subdirectories
        Iterator it = root.sortedIterator();
        while (it.hasNext()) {
            dirNumber++;
            dir = (ISO9660Directory) it.next();

            // Retrieve parent directory number and reset filename clash detection if appropriate
            int parent = ((Integer) parentMapper.get(dir.getParentDirectory())).intValue();

            DataReference ref = helper.getFilenameDataReference(dir);
            ISO9660PathTableRecord ptr = new ISO9660PathTableRecord(streamHandler, type, ref, parent);
            ptFixups.put(dir, ptr.doPTR());
            parentMapper.put(dir, new Integer(dirNumber));
        }

        if (volumeFixups.containsKey("ptSizeFixup")) {
            int ptSize = helper.getDifferenceTo(position);
            Fixup ptSizeFixup = (Fixup) volumeFixups.get("ptSizeFixup");
            ptSizeFixup.data(new BothWordDataReference(ptSize));
            ptSizeFixup.close();
            volumeFixups.remove("ptSizeFixup");
        }

        streamHandler.endElement();
    }
View Full Code Here

    private void doRootDirFixups(HashMap parentMapper) throws HandlerException {
        ParentInfo parentInfo = (ParentInfo) parentMapper.get(root);

        // Write and close Root Directory Location Fixup
        Fixup rootDirLocationFixup = (Fixup) volumeFixups.get("rootDirLocationFixup");
        rootDirLocationFixup.data(new BothWordDataReference(parentInfo.location));
        rootDirLocationFixup.close();
        volumeFixups.remove("rootDirLocationFixup");

        // Write and close Root Directory Length Fixup
        Fixup rootDirLengthFixup = (Fixup) volumeFixups.get("rootDirLengthFixup");
        rootDirLengthFixup.data(new BothWordDataReference(parentInfo.length));
        rootDirLengthFixup.close();
        volumeFixups.remove("rootDirLengthFixup");
    }
View Full Code Here

        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();
    }
View Full Code Here

        if (drLength > 0xFF) {
            throw new HandlerException("Invalid Directory Record Length: " + drLength);
        }

        // Write and close Directory Record Length Fixup
        Fixup drLengthFixup = (Fixup) memory.get("drLengthFixup");
        drLengthFixup.data(new ByteDataReference(drLength));
        drLengthFixup.close();
        memory.remove("drLengthFixup");

        return memory;
    }
View Full Code Here

        file.setIsMovedDirectory();
        ISO9660DirectoryRecord dr = new ISO9660DirectoryRecord(streamHandler, file, helper);
        HashMap memory = dr.doDR();

        // Remember Location Fixup
        Fixup locationFixup = (Fixup) memory.get("drLocationFixup");
        emptyFileFixups.add(locationFixup);

        // Write and close Length Fixup
        Fixup dataLengthFixup = (Fixup) memory.get("drDataLengthFixup");
        dataLengthFixup.data(new BothWordDataReference(0));
        dataLengthFixup.close();

        return memory;
    }
View Full Code Here

    HashMap doDR(ISO9660File file) throws HandlerException {
        ISO9660DirectoryRecord dr = new ISO9660DirectoryRecord(streamHandler, file, helper);
        HashMap memory = dr.doDR();

        // Remember Location Fixup
        Fixup locationFixup = (Fixup) memory.get("drLocationFixup");
        if (fileFixups.containsKey(file.getID())) {
            throw new RuntimeException("Duplicate file encountered: " + file.getISOPath());
        }
        fileFixups.put(file.getID(), locationFixup);

        // Write and close Length Fixup
        Fixup dataLengthFixup = (Fixup) memory.get("drDataLengthFixup");
        dataLengthFixup.data(new BothWordDataReference(file.length()));
        dataLengthFixup.close();

        return memory;
    }
View Full Code Here

    public void doFileFixup(ISO9660File file) throws HandlerException {
        if (!fileFixups.containsKey(file.getID())) {
            throw new RuntimeException("File " + file.getID() + " missing: " + file.getISOPath());
        }
        Fixup locationFixup = (Fixup) fileFixups.get(file.getID());

        int location = helper.getCurrentLocation();

        // Hardlink support for ISO9660Files that have the same underlying File
        if (locationFixups.containsKey(file.getContentID())) {
            location = ((Integer) locationFixups.get(file.getContentID())).intValue();
        } else {
            locationFixups.put(file.getContentID(), new Integer(location));
        }

        // Write and close File Fixup
        locationFixup.data(new BothWordDataReference(location));
        locationFixup.close();
    }
View Full Code Here

        while (it.hasNext()) {
            streamHandler.startElement(new LogicalSectorElement("DUMMY"));

            // Write and close Empty File Fixup
            int location = helper.getCurrentLocation();
            Fixup locationFixup = (Fixup) it.next();
            locationFixup.data(new BothWordDataReference(location));
            locationFixup.close();

            streamHandler.endElement();
        }
    }
View Full Code Here

TOP

Related Classes of com.github.stephenc.javaisotools.sabre.Fixup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.