Package org.jnode.fs.hfsplus.tree

Examples of org.jnode.fs.hfsplus.tree.NodeDescriptor


                BTHeaderRecord.BT_HEADER_RECORD_LENGTH);
            catalogFile.read(fs, 0, buffer);
            buffer.rewind();
            byte[] data = ByteBufferUtils.toArray(buffer);
            log.info("Load catalog node descriptor.");
            btnd = new NodeDescriptor(data, 0);
            log.debug(btnd.toString());
            log.info("Load catalog header record.");
            bthr = new BTHeaderRecord(data, NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH);
            log.debug(bthr.toString());
View Full Code Here


        log.info("Create B-Tree catalog file.");
        this.fs = fs;
        int nodeSize = params.getCatalogNodeSize();
        int bufferLength = 0;
        log.info("Create catalog node descriptor.");
        btnd = new NodeDescriptor(0, 0, NodeDescriptor.BT_HEADER_NODE, 0, 3);
        log.debug(btnd.toString());
        bufferLength += NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH;
        //
        int totalNodes = params.getCatalogClumpSize() / params.getCatalogNodeSize();
        int freeNodes = totalNodes - 2;
View Full Code Here

        fs.getApi().write(offset, this.getBytes());
    }

    private CatalogLeafNode createRootNode(HFSPlusParams params) {
        int nodeSize = params.getCatalogNodeSize();
        NodeDescriptor nd =
            new NodeDescriptor(0, 0, NodeDescriptor.BT_LEAF_NODE, 1,
                params.getInitializeNumRecords());
        CatalogLeafNode rootNode = new CatalogLeafNode(nd, nodeSize);
        // First record (folder)
        HfsUnicodeString name = new HfsUnicodeString(params.getVolumeName());
        CatalogKey ck = new CatalogKey(CatalogNodeId.HFSPLUS_POR_CNID, name);
View Full Code Here

        CatalogLeafNode node;
        HfsUnicodeString name = new HfsUnicodeString(filename);
        // find parent leaf record.
        LeafRecord record = this.getRecord(parentId, name);
        if (record == null) {
            NodeDescriptor nd = new NodeDescriptor(0, 0, NodeDescriptor.BT_LEAF_NODE, 1, 2);
            node = new CatalogLeafNode(nd, 8192);
            // Normal record
            CatalogKey key = new CatalogKey(parentId, name);
            if (nodeType == CatalogFolder.RECORD_TYPE_FOLDER) {
                CatalogFolder folder = new CatalogFolder(0, parentId);
View Full Code Here

        int nodeSize = bthr.getNodeSize();
        ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
        catalogFile.read(fs, (bthr.getRootNode() * nodeSize), nodeData);
        nodeData.rewind();
        byte[] data = ByteBufferUtils.toArray(nodeData);
        NodeDescriptor nd = new NodeDescriptor(nodeData.array(), 0);

        while (nd.isIndexNode()) {
            CatalogIndexNode node = new CatalogIndexNode(data, nodeSize);
            IndexRecord record = (IndexRecord) node.find(new CatalogKey(parentID));
            currentOffset = record.getIndex() * nodeSize;
            nodeData = ByteBuffer.allocate(nodeSize);
            catalogFile.read(fs, currentOffset, nodeData);
            nodeData.rewind();
            data = ByteBufferUtils.toArray(nodeData);
            nd = new NodeDescriptor(nodeData.array(), 0);
        }

        if (nd.isLeafNode()) {
            CatalogLeafNode node = new CatalogLeafNode(data, nodeSize);
            lr = (LeafRecord) node.find(new CatalogKey(parentID));
        }
        return lr;
    }
View Full Code Here

            long currentNodeNumber = nodeNumber;
            int nodeSize = getBTHeaderRecord().getNodeSize();
            ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
            catalogFile.read(fs, (currentNodeNumber * nodeSize), nodeData);
            byte[] datas = nodeData.array();
            NodeDescriptor nd = new NodeDescriptor(datas, 0);
            if (nd.isIndexNode()) {
                CatalogIndexNode node = new CatalogIndexNode(datas, nodeSize);
                IndexRecord[] records = node.findAll(new CatalogKey(parentID));
                List<LeafRecord> lfList = new LinkedList<LeafRecord>();
                for (IndexRecord rec : records) {
                    LeafRecord[] lfr = getRecords(parentID, rec.getIndex());
                    Collections.addAll(lfList, lfr);
                }
                return lfList.toArray(new LeafRecord[lfList.size()]);
            } else if (nd.isLeafNode()) {
                CatalogLeafNode node = new CatalogLeafNode(nodeData.array(), nodeSize);
                return node.findAll(new CatalogKey(parentID));
            } else {
                log.info(
                    String.format("Node %d wasn't a leaf or index: %s\n%s", nodeNumber, nd, NumberUtils.hex(datas)));
View Full Code Here

        throws IOException {
        long currentNodeNumber = getBTHeaderRecord().getRootNode();
        int nodeSize = getBTHeaderRecord().getNodeSize();
        ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
        catalogFile.read(fs, (currentNodeNumber * nodeSize), nodeData);
        NodeDescriptor nd = new NodeDescriptor(nodeData.array(), 0);
        long currentOffset = 0;
        CatalogKey cKey = new CatalogKey(parentID, nodeName);
        while (nd.isIndexNode()) {
            CatalogIndexNode node = new CatalogIndexNode(nodeData.array(), nodeSize);
            IndexRecord record = node.find(cKey);
            currentNodeNumber = record.getIndex();
            currentOffset = record.getIndex() * nodeSize;
            nodeData = ByteBuffer.allocate(nodeSize);
            catalogFile.read(fs, currentOffset, buffer);
            node = new CatalogIndexNode(nodeData.array(), nodeSize);
        }
        LeafRecord lr = null;
        if (nd.isLeafNode()) {
            CatalogLeafNode node = new CatalogLeafNode(nodeData.array(), nodeSize);
            lr = node.find(cKey);
        }
        return lr;
    }
View Full Code Here

    private ByteBuffer buffer;

    public Extent(HFSPlusParams params) {
        log.info("Create B-Tree extent file.");
        btnd = new NodeDescriptor(0, 0, NodeDescriptor.BT_HEADER_NODE, 0, 3);
        //
        int totalNodes = params.getExtentClumpSize() / params.getExtentNodeSize();
        int freeNodes = totalNodes - 1;
        bthr = new BTHeaderRecord(0, 0, 0, 0, 0, params.getExtentNodeSize(),
            ExtentKey.MAXIMUM_KEY_LENGTH, totalNodes, freeNodes,
View Full Code Here

                BTHeaderRecord.BT_HEADER_RECORD_LENGTH);
            extentFile.read(fs, 0, buffer);
            buffer.rewind();
            byte[] data = ByteBufferUtils.toArray(buffer);
            log.debug("Load extent node descriptor.");
            btnd = new NodeDescriptor(data, 0);
            log.debug(btnd.toString());
            log.debug("Load extent header record.");
            bthr = new BTHeaderRecord(data, NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH);
            log.debug(bthr.toString());
        }
View Full Code Here

            long currentNodeNumber = nodeNumber;
            int nodeSize = bthr.getNodeSize();
            ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
            extentFile.read(fs, (currentNodeNumber * nodeSize), nodeData);
            byte[] data = nodeData.array();
            NodeDescriptor nd = new NodeDescriptor(data, 0);

            if (nd.isIndexNode()) {
                ExtentNode extentNode = new ExtentNode(data, nodeSize);

                IndexRecord[] records = extentNode.findAll(key);
                List<ExtentDescriptor> overflowExtents = new LinkedList<ExtentDescriptor>();
                for (IndexRecord record : records) {
                    Collections.addAll(overflowExtents, getOverflowExtents(key, record.getIndex()));
                }

                return overflowExtents.toArray(new ExtentDescriptor[overflowExtents.size()]);

            } else if (nd.isLeafNode()) {
                ExtentLeafNode node = new ExtentLeafNode(nodeData.array(), nodeSize);
                return node.getOverflowExtents(key);

            } else {
                log.info(
View Full Code Here

TOP

Related Classes of org.jnode.fs.hfsplus.tree.NodeDescriptor

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.