Package org.jnode.fs.hfsplus.tree

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


        // First record (folder)
        HfsUnicodeString name = new HfsUnicodeString(params.getVolumeName());
        CatalogKey ck = new CatalogKey(CatalogNodeId.HFSPLUS_POR_CNID, name);
        CatalogFolder folder =
            new CatalogFolder(params.isJournaled() ? 2 : 0, CatalogNodeId.HFSPLUS_ROOT_CNID);
        LeafRecord record = new LeafRecord(ck, folder.getBytes());
        rootNode.addNodeRecord(record);
        // Second record (thread)
        CatalogKey tck = new CatalogKey(CatalogNodeId.HFSPLUS_POR_CNID, name);
        CatalogThread ct =
            new CatalogThread(CatalogFolder.RECORD_TYPE_FOLDER_THREAD,
                CatalogNodeId.HFSPLUS_ROOT_CNID, new HfsUnicodeString(""));
        record = new LeafRecord(tck, ct.getBytes());
        rootNode.addNodeRecord(record);
        log.debug(rootNode.toString());
        return rootNode;
    }
View Full Code Here


    public CatalogLeafNode createNode(String filename, CatalogNodeId parentId, CatalogNodeId nodeId,
                                      int nodeType) throws IOException {
        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);
                key = new CatalogKey(parentId, name);
                record = new LeafRecord(key, folder.getBytes());
                node.addNodeRecord(record);
            } else {
                // Catalog file
            }
            // Thread record
            key = new CatalogKey(parentId, name);
            int threadType;
            if (nodeType == CatalogFolder.RECORD_TYPE_FOLDER) {
                threadType = CatalogFolder.RECORD_TYPE_FOLDER_THREAD;
            } else {
                threadType = CatalogFile.RECORD_TYPE_FILE_THREAD;
            }
            CatalogThread thread = new CatalogThread(threadType, nodeId, name);
            record = new LeafRecord(key, thread.getBytes());
            node.addNodeRecord(record);

        } else {
            throw new IOException("Leaf record for parent (" + parentId.getId() + ") doesn't exist.");
        }
View Full Code Here

     * @return the leaf record, or possibly {code null}.
     * @throws IOException
     */
    public final LeafRecord getRecord(final CatalogNodeId parentID) throws IOException {
        long currentOffset = 0;
        LeafRecord lr = null;
        int nodeSize = bthr.getNodeSize();
        ByteBuffer nodeData = ByteBuffer.allocate(nodeSize);
        catalogFile.read(fs, (bthr.getRootNode() * nodeSize), nodeData);
        nodeData.rewind();
        byte[] data = ByteBufferUtils.toArray(nodeData);
View Full Code Here

            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

        return new CatalogKey(nodeData, offset);
    }

    @Override
    protected LeafRecord createRecord(Key key, byte[] nodeData, int offset, int recordSize) {
        return new LeafRecord(key, nodeData, offset, recordSize);
    }
View Full Code Here

        return new ExtentKey(nodeData, offset);
    }

    @Override
    protected LeafRecord createRecord(Key key, byte[] nodeData, int offset, int recordSize) {
        return new LeafRecord(key, nodeData, offset, recordSize);
    }
View Full Code Here

    }

    @Override
    protected final HfsPlusEntry createRootEntry() throws IOException {
        log.info("Create root entry.");
        LeafRecord record = catalog.getRecord(CatalogNodeId.HFSPLUS_POR_CNID);
        if (record != null) {
            return new HfsPlusEntry(this, null, "/", record);
        }
        log.error("Root entry : No record found.");
        return null;
View Full Code Here

        return -1;
    }

    @Override
    public String getVolumeName() throws IOException {
        LeafRecord record = catalog.getRecord(CatalogNodeId.HFSPLUS_POR_CNID);
        return ((CatalogKey) record.getKey()).getNodeName().getUnicodeString();
    }
View Full Code Here

TOP

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

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.