Revision: 5887 http://jnode.svn.sourceforge.net/jnode/?rev=5887&view=rev Author: galatnm Date: 2012-02-15 16:36:17 +0000 (Wed, 15 Feb 2012) Log Message: ----------- HFS : Rewrite folder operations (in progress).
Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusDirectory.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusDirectory.java 2012-02-14 16:05:35 UTC (rev 5886) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusDirectory.java 2012-02-15 16:36:17 UTC (rev 5887) @@ -76,7 +76,6 @@ @Override public FSEntry addFile(String name) throws IOException { - log.debug("<<< BEGIN addFile " + name + " >>>"); if (getFileSystem().isReadOnly()) { throw new ReadOnlyFileSystemException(); } @@ -86,7 +85,6 @@ FSEntry newEntry = createFileEntry(name); setFreeEntry(newEntry); - log.debug("<<< END addFile " + name + " >>>"); return newEntry; } @@ -111,7 +109,6 @@ @Override public void flush() throws IOException { - log.debug("<<< BEGIN flush >>>"); if (getFileSystem().isReadOnly()) { throw new ReadOnlyFileSystemException(); } @@ -121,7 +118,7 @@ // entries.resetDirty(); entry.resetDirty(); } - log.debug("<<< END flush >>>"); + log.debug("Directory flushed."); } @Override @@ -181,7 +178,6 @@ entries = FSEntryTable.EMPTY_TABLE; } } - log.debug("<<< END checkEntriesLoaded >>>"); } /** Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2012-02-14 16:05:35 UTC (rev 5886) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2012-02-15 16:36:17 UTC (rev 5887) @@ -110,11 +110,33 @@ BTHeaderRecord.BT_BIG_KEYS_MASK); log.debug(bthr.toString()); bufferLength += BTHeaderRecord.BT_HEADER_RECORD_LENGTH; + log.info("Create root node."); int rootNodePosition = bthr.getRootNode() * nodeSize; bufferLength += (rootNodePosition - bufferLength); - // Create node descriptor - NodeDescriptor nd = + CatalogLeafNode rootNode = createRootNode(params); + buffer = ByteBuffer.allocate(bufferLength + bthr.getNodeSize()); + buffer.put(btnd.getBytes()); + buffer.put(bthr.getBytes()); + buffer.position(rootNodePosition); + buffer.put(rootNode.getBytes()); + buffer.rewind(); + } + + /** + * Save catalog file to disk. + * + * @throws IOException + */ + public void update() throws IOException { + SuperBlock vh = fs.getVolumeHeader(); + long offset = vh.getCatalogFile().getExtent(0).getStartOffset(vh.getBlockSize()); + 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); @@ -133,26 +155,10 @@ record = new LeafRecord(tck, ct.getBytes()); rootNode.addNodeRecord(record); log.debug(rootNode.toString()); - buffer = ByteBuffer.allocate(bufferLength + bthr.getNodeSize()); - buffer.put(btnd.getBytes()); - buffer.put(bthr.getBytes()); - buffer.position(rootNodePosition); - buffer.put(rootNode.getBytes()); - buffer.rewind(); + return rootNode; } /** - * Save catalog file to disk. - * - * @throws IOException - */ - public void update() throws IOException { - SuperBlock vh = fs.getVolumeHeader(); - long offset = vh.getCatalogFile().getExtent(0).getStartOffset(vh.getBlockSize()); - fs.getApi().write(offset, this.getBytes()); - } - - /** * Create a new node in the catalog B-Tree. * * @param filename @@ -165,6 +171,7 @@ 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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits