From: <ga...@us...> - 2009-01-04 12:22:15
|
Revision: 4825 http://jnode.svn.sourceforge.net/jnode/?rev=4825&view=rev Author: galatnm Date: 2009-01-04 11:42:26 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Fix checkstyle warnings. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNodeId.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentIndexNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractKey.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -33,20 +33,20 @@ @Override protected final FSEntry createDirectoryEntry(final String name) throws IOException { - if(!canWrite()){ - throw new ReadOnlyFileSystemException(); - } - Superblock volumeHeader = ((HfsPlusFileSystem) getFileSystem()).getVolumeHeader(); - CatalogFolder newFolder = new CatalogFolder(new CatalogNodeId(volumeHeader.getNextCatalogId())); - log.debug("New catalog folder :\n" + newFolder.toString()); - CatalogKey key = new CatalogKey(this.folder.getFolderId(),new HFSUnicodeString(name)); - log.debug("New catalog key :\n" + key.toString()); - LeafRecord folderRecord = new LeafRecord(key,newFolder.getBytes()); - log.debug("New record folder :\n" + folderRecord.toString()); - HFSPlusEntry newEntry = new HFSPlusEntry( (HfsPlusFileSystem) getFileSystem(),null,this,name,folderRecord); - volumeHeader.setFolderCount(volumeHeader.getFolderCount() + 1); - log.debug("New volume header :\n" + volumeHeader.toString()); - return newEntry; + if (!canWrite()) { + throw new ReadOnlyFileSystemException(); + } + Superblock volumeHeader = ((HfsPlusFileSystem) getFileSystem()).getVolumeHeader(); + CatalogFolder newFolder = new CatalogFolder(new CatalogNodeId(volumeHeader.getNextCatalogId())); + log.debug("New catalog folder :\n" + newFolder.toString()); + CatalogKey key = new CatalogKey(this.folder.getFolderId(), new HFSUnicodeString(name)); + log.debug("New catalog key :\n" + key.toString()); + LeafRecord folderRecord = new LeafRecord(key, newFolder.getBytes()); + log.debug("New record folder :\n" + folderRecord.toString()); + HFSPlusEntry newEntry = new HFSPlusEntry((HfsPlusFileSystem) getFileSystem(), null, this, name, folderRecord); + volumeHeader.setFolderCount(volumeHeader.getFolderCount() + 1); + log.debug("New volume header :\n" + volumeHeader.toString()); + return newEntry; } @Override @@ -61,14 +61,12 @@ @Override protected final FSEntryTable readEntries() throws IOException { List<FSEntry> pathList = new LinkedList<FSEntry>(); - LeafRecord[] records = - ((HfsPlusFileSystem) getFileSystem()).getCatalog().getRecords(folder.getFolderId()); + LeafRecord[] records = ((HfsPlusFileSystem) getFileSystem()).getCatalog().getRecords(folder.getFolderId()); for (LeafRecord rec : records) { - if (rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER || - rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE) { + if (rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER + || rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE) { String name = ((CatalogKey) rec.getKey()).getNodeName().getUnicodeString(); - HFSPlusEntry e = - new HFSPlusEntry((HfsPlusFileSystem) getFileSystem(), null, this, name, rec); + HFSPlusEntry e = new HFSPlusEntry((HfsPlusFileSystem) getFileSystem(), null, this, name, rec); pathList.add(e); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -8,8 +8,8 @@ private LeafRecord record; - public HFSPlusEntry(final HfsPlusFileSystem fs, final FSEntryTable table, - final HFSPlusDirectory parent, final String name, final LeafRecord record) { + public HFSPlusEntry(final HfsPlusFileSystem fs, final FSEntryTable table, final HFSPlusDirectory parent, + final String name, final LeafRecord record) { super(fs, table, parent, name, getFSEntryType(name, record)); this.record = record; } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -8,7 +8,7 @@ private static final int EXTENT_OFFSET = 16; private byte[] data; - + /** * * @param src @@ -18,7 +18,7 @@ data = new byte[FORK_DATA_LENGTH]; System.arraycopy(src, offset, data, 0, FORK_DATA_LENGTH); } - + /** * * Create a new empty fork data object. @@ -27,50 +27,49 @@ * @param clumpSize * @param totalBock */ - public HFSPlusForkData(){ - data = new byte[FORK_DATA_LENGTH]; + public HFSPlusForkData() { + data = new byte[FORK_DATA_LENGTH]; } public final long getTotalSize() { return BigEndian.getInt64(data, 0); } - public final void setTotalSize(long totalSize){ - BigEndian.setInt64(data, 0, totalSize); + public final void setTotalSize(long totalSize) { + BigEndian.setInt64(data, 0, totalSize); } - + public final int getClumpSize() { return BigEndian.getInt32(data, 8); } - public final void setClumpSize(int clumpSize){ - BigEndian.setInt32(data, 8, clumpSize); + public final void setClumpSize(int clumpSize) { + BigEndian.setInt32(data, 8, clumpSize); } - + public final int getTotalBlocks() { return BigEndian.getInt32(data, 12); } - public final void setTotalBlocks(int totalBlock){ - BigEndian.setInt32(data, 12, totalBlock); + public final void setTotalBlocks(int totalBlock) { + BigEndian.setInt32(data, 12, totalBlock); } - + public final ExtentDescriptor[] getExtents() { ExtentDescriptor[] list = new ExtentDescriptor[8]; for (int i = 0; i < 8; i++) { - list[i] = new ExtentDescriptor( - data, EXTENT_OFFSET + (i * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH)); + list[i] = new ExtentDescriptor(data, EXTENT_OFFSET + (i * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH)); } return list; } - - public final void setExtentDescriptor(int position, ExtentDescriptor desc){ - int offset = EXTENT_OFFSET + (position * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH); - System.arraycopy(desc.getBytes(), 0, data, offset, ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH); + + public final void setExtentDescriptor(int position, ExtentDescriptor desc) { + int offset = EXTENT_OFFSET + (position * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH); + System.arraycopy(desc.getBytes(), 0, data, offset, ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH); } - - public byte[] getBytes(){ - return data; + + public byte[] getBytes() { + return data; } public final String toString() { Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -2,19 +2,19 @@ import org.jnode.util.BigEndian; - public class HFSUnicodeString { /** Length of string in characters. */ private int length; private String string; + /** * * @param src * @param offset */ public HFSUnicodeString(final byte[] src, final int offset) { - length = BigEndian.getInt16(src, offset); + length = BigEndian.getInt16(src, offset); byte[] data = new byte[2 + length * 2]; System.arraycopy(src, offset, data, 0, 2); length = BigEndian.getInt16(data, 0); @@ -26,14 +26,14 @@ } string = new String(result); } - + /** * * @param string */ - public HFSUnicodeString(String string){ - this.string = string; - this.length = string.length(); + public HFSUnicodeString(String string) { + this.string = string; + this.length = string.length(); } public final int getLength() { @@ -43,9 +43,9 @@ public final String getUnicodeString() { return string; } - - public final byte[] getBytes(){ - return (length + "" + string).getBytes() ; + + public final byte[] getBytes() { + return (length + "" + string).getBytes(); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -4,27 +4,29 @@ import java.util.Calendar; public class HFSUtils { - - /** - * Difference in second between 01/01/1970 00:00:00 (java reference time) - * and 01/01/1904 00:00:00 (HFS reference time). - */ + + /** + * Difference in second between 01/01/1970 00:00:00 (java reference time) + * and 01/01/1904 00:00:00 (HFS reference time). + */ public static final long MAC_DATE_CONVERTION = 2082844800L; /** * Convert time from/to java time to/from mac time. - * - * @param time in seconds since reference date. - * @param encode if set to true, convert from java to mac. If set to false, - * convert from mac to java. * + * @param time + * in seconds since reference date. + * @param encode + * if set to true, convert from java to mac. If set to false, + * convert from mac to java. + * * @return */ - public static long getDate(long time, boolean encode){ - time = (encode)? time + MAC_DATE_CONVERTION:time - MAC_DATE_CONVERTION; - return time; + public static long getDate(long time, boolean encode) { + time = (encode) ? time + MAC_DATE_CONVERTION : time - MAC_DATE_CONVERTION; + return time; } - + /** * * @param time @@ -32,8 +34,8 @@ * @return */ public static String printDate(final long time, final String dateFormat) { - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(getDate(time, false)*1000); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(getDate(time, false) * 1000); SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(cal.getTime()); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -5,7 +5,7 @@ public static final int HFSPLUS_MIN_VERSION = 0x0004; /* HFS+ */ public static final int HFSPLUS_CURRENT_VERSION = 5; /* HFSX */ - + /* HFS+ volume attributes */ public static final int HFSPLUS_VOL_UNMNT_BIT = 8; public static final int HFSPLUS_VOL_SPARE_BLK_BIT = 9; @@ -14,12 +14,12 @@ public static final int HFSPLUS_VOL_NODEID_REUSED_BIT = 12; public static final int HFSPLUS_VOL_JOURNALED_BIT = 13; public static final int HFSPLUS_VOL_SOFTLOCK_BIT = 15; - + public static final int BT_LEAF_NODE = -1; public static final int BT_INDEX_NODE = 0; public static final int BT_HEADER_NODE = 1; public static final int BT_MAP_NODE = 2; - + /* Types */ public static final int RECORD_TYPE_FOLDER = 0x0001; public static final int RECORD_TYPE_FILE = 0x0002; @@ -32,10 +32,10 @@ public static final byte EK_DATA_FORK = (byte) 0x00; public static final byte EK_RESOURCE_FORK = (byte) 0xFF; - + public static final int MINIMAL_BLOCK_SIZE = 512; public static final int OPTIMAL_BLOCK_SIZE = 4096; - + public static final int DATA_CLUMP_FACTOR = 16; public static final int RESOURCE_CLUMP_FACTOR = 16; } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -15,7 +15,6 @@ import org.jnode.fs.hfsplus.tree.LeafRecord; import org.jnode.fs.spi.AbstractFileSystem; - public class HfsPlusFileSystem extends AbstractFileSystem<HFSPlusEntry> { private final Logger log = Logger.getLogger(getClass()); @@ -32,13 +31,11 @@ * @param type * @throws FileSystemException */ - public HfsPlusFileSystem(final Device device, final boolean readOnly, - final HfsPlusFileSystemType type) throws FileSystemException { + public HfsPlusFileSystem(final Device device, final boolean readOnly, final HfsPlusFileSystemType type) + throws FileSystemException { super(device, readOnly, type); } - - /** * * @throws FileSystemException @@ -48,8 +45,7 @@ log.debug("Superblock informations:\n" + sb.toString()); if (!sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_UNMNT_BIT)) { - log.info(getDevice().getId() + - " Filesystem has not been cleanly unmounted, mounting it readonly"); + log.info(getDevice().getId() + " Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } if (sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_SOFTLOCK_BIT)) { @@ -57,8 +53,8 @@ setReadOnly(true); } if (sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_JOURNALED_BIT)) { - log.info(getDevice().getId() + - " Filesystem is journaled, write access is not supported. Mounting it readonly"); + log.info(getDevice().getId() + + " Filesystem is journaled, write access is not supported. Mounting it readonly"); setReadOnly(true); } try { @@ -110,21 +106,21 @@ public final Superblock getVolumeHeader() { return sb; } - + /** * * @throws FileSystemException */ public void create(int blockSize) throws FileSystemException { - sb = new Superblock(); - try { - sb.create(this,blockSize, false); - this.getApi().write(1024, ByteBuffer.wrap(sb.getBytes())); - flush(); - } catch (IOException e) { - throw new FileSystemException("Unable to create HFS+ filesystem", e); - } catch (ApiNotFoundException e) { - throw new FileSystemException("Unable to create HFS+ filesystem", e); - } + sb = new Superblock(); + try { + sb.create(this, blockSize, false); + this.getApi().write(1024, ByteBuffer.wrap(sb.getBytes())); + flush(); + } catch (IOException e) { + throw new FileSystemException("Unable to create HFS+ filesystem", e); + } catch (ApiNotFoundException e) { + throw new FileSystemException("Unable to create HFS+ filesystem", e); + } } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -15,8 +15,7 @@ public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> { public static final Class<HfsPlusFileSystemType> ID = HfsPlusFileSystemType.class; - public final HfsPlusFileSystem create(final Device device, final boolean readOnly) - throws FileSystemException { + public final HfsPlusFileSystem create(final Device device, final boolean readOnly) throws FileSystemException { HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly, this); fs.read(); return fs; @@ -26,7 +25,7 @@ return "HFS+"; } - public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector, + public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector, final FSBlockDeviceAPI devApi) { if (pte != null) { if (pte instanceof IBMPartitionTableEntry) { Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -19,19 +19,18 @@ import org.jnode.util.BigEndian; import org.jnode.util.NumberUtils; - /** * HFS+ volume header definition. * * @author Fabien L. * */ -public class Superblock extends HFSPlusObject { +public class Superblock extends HFSPlusObject { private final Logger log = Logger.getLogger(getClass()); - + /** Volume header data length */ public static final int SUPERBLOCK_LENGTH = 1024; - + /** Data bytes array that contains volume header information */ private byte[] data; @@ -43,20 +42,24 @@ data = new byte[SUPERBLOCK_LENGTH]; log.setLevel(Level.INFO); } - + /** - * Create the volume header and load information for the file system passed as parameter. - * - * @param fs The file system contains HFS+ partition. + * Create the volume header and load information for the file system passed + * as parameter. * - * @throws FileSystemException If magic number (0X482B) is incorrect or not available. + * @param fs + * The file system contains HFS+ partition. + * + * @throws FileSystemException + * If magic number (0X482B) is incorrect or not available. */ public Superblock(final HfsPlusFileSystem fs) throws FileSystemException { super(fs); log.setLevel(Level.INFO); try { ByteBuffer b = ByteBuffer.allocate(SUPERBLOCK_LENGTH); - // skip the first 1024 bytes (boot sector) and read the volume header. + // skip the first 1024 bytes (boot sector) and read the volume + // header. fs.getApi().read(1024, b); data = new byte[SUPERBLOCK_LENGTH]; System.arraycopy(b.array(), 0, data, 0, SUPERBLOCK_LENGTH); @@ -67,82 +70,82 @@ throw new FileSystemException(e); } } - - - + /** * Create a new volume header. * * @param fs * @param blockSize - * @throws ApiNotFoundException + * @throws ApiNotFoundException */ - public void create(HfsPlusFileSystem fs, int blockSize,boolean journaled) throws IOException, ApiNotFoundException, FileSystemException { - - this.fs = fs; - int burnedBlocksBeforeVH = 0; - int burnedBlocksAfterAltVH = 0; - /* - * Volume header is located at sector 2. Block before this position - * must be invalidated. - */ - if ( blockSize == 512 ) { - burnedBlocksBeforeVH = 2; - burnedBlocksAfterAltVH = 1; - } else if ( blockSize == 1024 ) { - burnedBlocksBeforeVH = 1; - } - long size = fs.getApi().getLength(); - long sectorCount = size / fs.getFSApi().getSectorSize(); - long blocks = size / blockSize; - long allocationClumpSize = getClumpSize(blocks); - long bitmapBlocks = allocationClumpSize/blockSize; - long blockUsed = 2+ burnedBlocksBeforeVH + burnedBlocksAfterAltVH + bitmapBlocks; - // Populate volume header. - this.setMagic(HfsPlusConstants.HFSPLUS_SUPER_MAGIC); - this.setVersion(HfsPlusConstants.HFSPLUS_MIN_VERSION); - //Set attributes. - this.setAttribute(HFSPLUS_VOL_UNMNT_BIT); - this.setLastMountedVersion(0x446534a); - //TODO Put correct dates. - Calendar now = Calendar.getInstance(); - now.setTime(new Date()); - int macDate = (int)HFSUtils.getDate(now.getTimeInMillis()/1000, true); - this.setCreateDate(macDate); - this.setModifyDate(macDate); - this.setBackupDate(0); - this.setCheckedDate(macDate); - //--- - this.setFileCount(0); - this.setFolderCount(0); - this.setBlockSize(blockSize); - this.setTotalBlocks((int)blocks); - this.setFreeBlocks((int)blocks); - this.setRsrcClumpSize(HfsPlusConstants.RESOURCE_CLUMP_FACTOR * blockSize); - this.setDataClumpSize(HfsPlusConstants.DATA_CLUMP_FACTOR * blockSize); - this.setNextCatalogId(CatalogNodeId.HFSPLUS_FIRSTUSER_CNID.getId()); - // Allocation file creation - initAllocationFile((int)allocationClumpSize, (int)bitmapBlocks, burnedBlocksBeforeVH); - int nextBlock = 0; - // Journal creation - ExtentDescriptor desc = this.getAllocationFile().getExtents()[0]; - if(journaled){ - int journalSize = 8*1024*1024; - this.setFileCount(2); - this.setAttribute(HFSPLUS_VOL_JOURNALED_BIT); - this.setNextCatalogId(this.getNextCatalogId() + 2); - this.setJournalInfoBlock(desc.getStartBlock() + desc.getBlockCount()); - blockUsed = blockUsed + 1 + (journalSize / blockSize); - } else { - this.setJournalInfoBlock(0); - nextBlock = desc.getStartBlock() + desc.getBlockCount(); - } - blockUsed += initExtents(0,blockSize,nextBlock, (int)sectorCount, blockUsed); - blockUsed += initCatalog(0,blockSize,nextBlock, (int)sectorCount, blockUsed); - this.setFreeBlocks(this.getFreeBlocks() - (int)blockUsed); - this.setNextAllocation((int)blockUsed - 1 - burnedBlocksAfterAltVH + 10 * (this.getCatalogFile().getClumpSize() / this.getBlockSize())); + public void create(HfsPlusFileSystem fs, int blockSize, boolean journaled) throws IOException, + ApiNotFoundException, FileSystemException { + + this.fs = fs; + int burnedBlocksBeforeVH = 0; + int burnedBlocksAfterAltVH = 0; + /* + * Volume header is located at sector 2. Block before this position must + * be invalidated. + */ + if (blockSize == 512) { + burnedBlocksBeforeVH = 2; + burnedBlocksAfterAltVH = 1; + } else if (blockSize == 1024) { + burnedBlocksBeforeVH = 1; + } + long size = fs.getApi().getLength(); + long sectorCount = size / fs.getFSApi().getSectorSize(); + long blocks = size / blockSize; + long allocationClumpSize = getClumpSize(blocks); + long bitmapBlocks = allocationClumpSize / blockSize; + long blockUsed = 2 + burnedBlocksBeforeVH + burnedBlocksAfterAltVH + bitmapBlocks; + // Populate volume header. + this.setMagic(HfsPlusConstants.HFSPLUS_SUPER_MAGIC); + this.setVersion(HfsPlusConstants.HFSPLUS_MIN_VERSION); + // Set attributes. + this.setAttribute(HFSPLUS_VOL_UNMNT_BIT); + this.setLastMountedVersion(0x446534a); + // TODO Put correct dates. + Calendar now = Calendar.getInstance(); + now.setTime(new Date()); + int macDate = (int) HFSUtils.getDate(now.getTimeInMillis() / 1000, true); + this.setCreateDate(macDate); + this.setModifyDate(macDate); + this.setBackupDate(0); + this.setCheckedDate(macDate); + // --- + this.setFileCount(0); + this.setFolderCount(0); + this.setBlockSize(blockSize); + this.setTotalBlocks((int) blocks); + this.setFreeBlocks((int) blocks); + this.setRsrcClumpSize(HfsPlusConstants.RESOURCE_CLUMP_FACTOR * blockSize); + this.setDataClumpSize(HfsPlusConstants.DATA_CLUMP_FACTOR * blockSize); + this.setNextCatalogId(CatalogNodeId.HFSPLUS_FIRSTUSER_CNID.getId()); + // Allocation file creation + initAllocationFile((int) allocationClumpSize, (int) bitmapBlocks, burnedBlocksBeforeVH); + int nextBlock = 0; + // Journal creation + ExtentDescriptor desc = this.getAllocationFile().getExtents()[0]; + if (journaled) { + int journalSize = 8 * 1024 * 1024; + this.setFileCount(2); + this.setAttribute(HFSPLUS_VOL_JOURNALED_BIT); + this.setNextCatalogId(this.getNextCatalogId() + 2); + this.setJournalInfoBlock(desc.getStartBlock() + desc.getBlockCount()); + blockUsed = blockUsed + 1 + (journalSize / blockSize); + } else { + this.setJournalInfoBlock(0); + nextBlock = desc.getStartBlock() + desc.getBlockCount(); + } + blockUsed += initExtents(0, blockSize, nextBlock, (int) sectorCount, blockUsed); + blockUsed += initCatalog(0, blockSize, nextBlock, (int) sectorCount, blockUsed); + this.setFreeBlocks(this.getFreeBlocks() - (int) blockUsed); + this.setNextAllocation((int) blockUsed - 1 - burnedBlocksAfterAltVH + 10 + * (this.getCatalogFile().getClumpSize() / this.getBlockSize())); } - + /** * * @param clumpSize @@ -150,18 +153,18 @@ * @param burnedBlocksBeforeVH * @return */ - private void initAllocationFile(int clumpSize, int bitmapBlocks, int burnedBlocksBeforeVH){ - HFSPlusForkData forkdata = new HFSPlusForkData(); - forkdata.setTotalSize(clumpSize); - forkdata.setClumpSize(clumpSize); - forkdata.setTotalBlocks(bitmapBlocks); - ExtentDescriptor desc = new ExtentDescriptor(); - desc.setStartBlock(1 + burnedBlocksBeforeVH); - desc.setBlockCount(0); - forkdata.setExtentDescriptor(0, desc); - System.arraycopy(forkdata.getBytes(), 0, data, 112, forkdata.FORK_DATA_LENGTH); + private void initAllocationFile(int clumpSize, int bitmapBlocks, int burnedBlocksBeforeVH) { + HFSPlusForkData forkdata = new HFSPlusForkData(); + forkdata.setTotalSize(clumpSize); + forkdata.setClumpSize(clumpSize); + forkdata.setTotalBlocks(bitmapBlocks); + ExtentDescriptor desc = new ExtentDescriptor(); + desc.setStartBlock(1 + burnedBlocksBeforeVH); + desc.setBlockCount(0); + forkdata.setExtentDescriptor(0, desc); + System.arraycopy(forkdata.getBytes(), 0, data, 112, forkdata.FORK_DATA_LENGTH); } - + /** * * @param extentsClumpBlock @@ -169,26 +172,26 @@ * @param nextBlock * @return */ - private long initExtents(int extentsClumpBlock, int blockSize, int nextBlock, int sectorCount, long blockUsed){ - int extentNodeSize = 4096; - long clumpSize = 0; - if(extentsClumpBlock == 0){ - clumpSize = getBTreeClumpSize(blockSize, extentNodeSize, sectorCount, false); - } else { - clumpSize = clumpSizeCalculation(extentsClumpBlock, blockSize); - } - HFSPlusForkData forkdata = new HFSPlusForkData(); - forkdata.setTotalSize(clumpSize); - forkdata.setClumpSize((int)clumpSize); - forkdata.setTotalBlocks((int)(clumpSize/blockSize)); - ExtentDescriptor desc = new ExtentDescriptor(); - desc.setStartBlock(nextBlock); - desc.setBlockCount(forkdata.getTotalBlocks()); - forkdata.setExtentDescriptor(0, desc); - System.arraycopy(forkdata.getBytes(), 0, data, 192, forkdata.FORK_DATA_LENGTH); - return blockUsed + forkdata.getTotalBlocks(); + private long initExtents(int extentsClumpBlock, int blockSize, int nextBlock, int sectorCount, long blockUsed) { + int extentNodeSize = 4096; + long clumpSize = 0; + if (extentsClumpBlock == 0) { + clumpSize = getBTreeClumpSize(blockSize, extentNodeSize, sectorCount, false); + } else { + clumpSize = clumpSizeCalculation(extentsClumpBlock, blockSize); + } + HFSPlusForkData forkdata = new HFSPlusForkData(); + forkdata.setTotalSize(clumpSize); + forkdata.setClumpSize((int) clumpSize); + forkdata.setTotalBlocks((int) (clumpSize / blockSize)); + ExtentDescriptor desc = new ExtentDescriptor(); + desc.setStartBlock(nextBlock); + desc.setBlockCount(forkdata.getTotalBlocks()); + forkdata.setExtentDescriptor(0, desc); + System.arraycopy(forkdata.getBytes(), 0, data, 192, forkdata.FORK_DATA_LENGTH); + return blockUsed + forkdata.getTotalBlocks(); } - + /** * * @param extentsClumpBlock @@ -197,57 +200,61 @@ * @param sectorCount * @param blockUsed * @return - * @throws IOException + * @throws IOException */ - private long initCatalog(int catalogClumpBlock, int blockSize, int nextBlock, int sectorCount, long blockUsed) throws FileSystemException{ - int catalogNodeSize = 8192; - try{ - if(blockSize < HfsPlusConstants.OPTIMAL_BLOCK_SIZE || fs.getApi().getLength() < 0x40000000){ - catalogNodeSize = 4096; - } - long clumpSize = 0; - if(catalogClumpBlock == 0){ - clumpSize = getBTreeClumpSize(blockSize, catalogNodeSize, sectorCount, true); - } else { - clumpSize = clumpSizeCalculation(catalogClumpBlock, blockSize); - if(clumpSize % catalogNodeSize != 0){ - throw new FileSystemException("clump size is not a multiple of node size"); - } - } - - HFSPlusForkData forkdata = new HFSPlusForkData(); - forkdata.setTotalSize(clumpSize); - forkdata.setClumpSize((int)clumpSize); - forkdata.setTotalBlocks((int)(clumpSize/blockSize)); - ExtentDescriptor desc = new ExtentDescriptor(); - desc.setStartBlock(this.getExtentsFile().getExtents()[0].getStartBlock() + this.getExtentsFile().getExtents()[0].getBlockCount()); - desc.setBlockCount(forkdata.getTotalBlocks()); - forkdata.setExtentDescriptor(0, desc); - System.arraycopy(forkdata.getBytes(), 0, data, 272, forkdata.FORK_DATA_LENGTH); - return blockUsed + forkdata.getTotalBlocks(); - } catch(IOException e){ - throw new FileSystemException(e); - } + private long initCatalog(int catalogClumpBlock, int blockSize, int nextBlock, int sectorCount, long blockUsed) + throws FileSystemException { + int catalogNodeSize = 8192; + try { + if (blockSize < HfsPlusConstants.OPTIMAL_BLOCK_SIZE || fs.getApi().getLength() < 0x40000000) { + catalogNodeSize = 4096; + } + long clumpSize = 0; + if (catalogClumpBlock == 0) { + clumpSize = getBTreeClumpSize(blockSize, catalogNodeSize, sectorCount, true); + } else { + clumpSize = clumpSizeCalculation(catalogClumpBlock, blockSize); + if (clumpSize % catalogNodeSize != 0) { + throw new FileSystemException("clump size is not a multiple of node size"); + } + } + + HFSPlusForkData forkdata = new HFSPlusForkData(); + forkdata.setTotalSize(clumpSize); + forkdata.setClumpSize((int) clumpSize); + forkdata.setTotalBlocks((int) (clumpSize / blockSize)); + ExtentDescriptor desc = new ExtentDescriptor(); + desc.setStartBlock(this.getExtentsFile().getExtents()[0].getStartBlock() + + this.getExtentsFile().getExtents()[0].getBlockCount()); + desc.setBlockCount(forkdata.getTotalBlocks()); + forkdata.setExtentDescriptor(0, desc); + System.arraycopy(forkdata.getBytes(), 0, data, 272, forkdata.FORK_DATA_LENGTH); + return blockUsed + forkdata.getTotalBlocks(); + } catch (IOException e) { + throw new FileSystemException(e); + } } - + /** * Calculate the number of blocks needed for bitmap. * - * @param totalBlocks Total of blocks found in the device. + * @param totalBlocks + * Total of blocks found in the device. * * @return long - Number of blocks. * * @throws IOException */ private long getClumpSize(long totalBlocks) throws IOException { - long clumpSize; - long minClumpSize = totalBlocks >> 3; - if ((totalBlocks & 7) == 0){ - ++minClumpSize; - } - clumpSize = minClumpSize; - return clumpSize; + long clumpSize; + long minClumpSize = totalBlocks >> 3; + if ((totalBlocks & 7) == 0) { + ++minClumpSize; + } + clumpSize = minClumpSize; + return clumpSize; } + /** * * @param blockSize @@ -257,39 +264,41 @@ * @return */ - private int[] extentClumpTable = new int[]{4,4,4,5,5,6,7,8,9,11,14,16,20,25,32}; - private int[] catalogClumpTable = new int[]{4,6,8,11,14,19,25,34,45,60,80,107,144,192,256}; - private long getBTreeClumpSize(int blockSize, int nodeSize, long sectors, boolean catalog){ - long clumpSize = 0; - if(sectors < 0x200000){ - clumpSize = (sectors << 2); - if(clumpSize < (8*nodeSize)){ - clumpSize = (8*nodeSize); - } - } else { - sectors = sectors >> 22; - for(int i=0;sectors != 0 && (i < 14);++i){ - if(catalog){ - clumpSize = catalogClumpTable[i] * 1024 * 1024; - } else { - clumpSize = extentClumpTable[i] * 1024 * 1024; - } - sectors = sectors >> 1; - } - } - - return clumpSize; + private int[] extentClumpTable = new int[] {4, 4, 4, 5, 5, 6, 7, 8, 9, 11, 14, 16, 20, 25, 32 }; + private int[] catalogClumpTable = new int[] {4, 6, 8, 11, 14, 19, 25, 34, 45, 60, 80, 107, 144, 192, 256 }; + + private long getBTreeClumpSize(int blockSize, int nodeSize, long sectors, boolean catalog) { + long clumpSize = 0; + if (sectors < 0x200000) { + clumpSize = (sectors << 2); + if (clumpSize < (8 * nodeSize)) { + clumpSize = (8 * nodeSize); + } + } else { + sectors = sectors >> 22; + for (int i = 0; sectors != 0 && (i < 14); ++i) { + if (catalog) { + clumpSize = catalogClumpTable[i] * 1024 * 1024; + } else { + clumpSize = extentClumpTable[i] * 1024 * 1024; + } + sectors = sectors >> 1; + } + } + + return clumpSize; } - - private int clumpSizeCalculation(long clumpBlocks, int blockSize){ - long clumpSize = clumpBlocks * blockSize; - if((clumpSize & 0XFFFFFFFF00000000L) == 0){ - //ERROR - } - return (int)clumpSize; + + private int clumpSizeCalculation(long clumpBlocks, int blockSize) { + long clumpSize = clumpBlocks * blockSize; + if ((clumpSize & 0XFFFFFFFF00000000L) == 0) { + // ERROR + } + return (int) clumpSize; } + // Getters/setters - + public final int getMagic() { return BigEndian.getInt16(data, 0); } @@ -309,12 +318,12 @@ // public final int getAttributes() { - + return BigEndian.getInt32(data, 4); } - + public final void setAttribute(final int attributeMaskBit) { - BigEndian.setInt32(data, 4,(getAttributes() >> attributeMaskBit) | 0x1); + BigEndian.setInt32(data, 4, (getAttributes() >> attributeMaskBit) | 0x1); } // @@ -487,51 +496,53 @@ public final HFSPlusForkData getStartupFile() { return new HFSPlusForkData(data, 432); } - + /** * Get string representation of attribute. * * @return */ public final String getAttributesAsString() { - return ((isAttribute(HFSPLUS_VOL_UNMNT_BIT)) ? " kHFSVolumeUnmountedBit" : "") + - ((isAttribute(HFSPLUS_VOL_INCNSTNT_BIT)) ? " kHFSBootVolumeInconsistentBit" : "") + - ((isAttribute(HFSPLUS_VOL_JOURNALED_BIT)) ? " kHFSVolumeJournaledBit" : ""); + return ((isAttribute(HFSPLUS_VOL_UNMNT_BIT)) ? " kHFSVolumeUnmountedBit" : "") + + ((isAttribute(HFSPLUS_VOL_INCNSTNT_BIT)) ? " kHFSBootVolumeInconsistentBit" : "") + + ((isAttribute(HFSPLUS_VOL_JOURNALED_BIT)) ? " kHFSVolumeJournaledBit" : ""); } /** * Check if the corresponding attribute corresponding is set. * - * @param maskBit Bit position of the attribute. See constants. + * @param maskBit + * Bit position of the attribute. See constants. * * @return true if attribute is set. */ public final boolean isAttribute(final int maskBit) { return (((getAttributes() >> maskBit) & 0x1) != 0); } - - public byte[] getBytes(){ - return data; + + public byte[] getBytes() { + return data; } /* * (non-Javadoc) + * * @see java.lang.Object#toString() */ public final String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Magic: 0x").append(NumberUtils.hex(getMagic(), 4)).append("\n"); buffer.append("Version: ").append(getVersion()).append("\n").append("\n"); - buffer.append("Attributes: ").append(getAttributesAsString()).append(" (").append(getAttributes()).append(")").append("\n").append("\n"); - buffer.append("Create date: ").append( - HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - buffer.append("Modify date: ").append( - HFSUtils.printDate(getModifyDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - buffer.append("Backup date: ").append( - HFSUtils.printDate(getBackupDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - buffer.append("Checked date: ").append( - HFSUtils.printDate(getCheckedDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n") - .append("\n"); + buffer.append("Attributes: ").append(getAttributesAsString()).append(" (").append(getAttributes()).append(")") + .append("\n").append("\n"); + buffer.append("Create date: ").append(HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n"); + buffer.append("Modify date: ").append(HFSUtils.printDate(getModifyDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n"); + buffer.append("Backup date: ").append(HFSUtils.printDate(getBackupDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n"); + buffer.append("Checked date: ").append(HFSUtils.printDate(getCheckedDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n").append("\n"); buffer.append("File count: ").append(getFileCount()).append("\n"); buffer.append("Folder count: ").append(getFolderCount()).append("\n").append("\n"); buffer.append("Block size: ").append(getBlockSize()).append("\n"); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -60,13 +60,12 @@ NodeDescriptor currentBtnd = new NodeDescriptor(nodeData.array()); log.debug("Current node descriptor:\n" + currentBtnd.toString()); while (currentBtnd.getKind() == HfsPlusConstants.BT_INDEX_NODE) { - CatalogIndexNode currentIndexNode = - new CatalogIndexNode(currentBtnd, nodeData.array(), currentNodeSize); + CatalogIndexNode currentIndexNode = new CatalogIndexNode(currentBtnd, nodeData.array(), currentNodeSize); IndexRecord record = currentIndexNode.find(parentID); currentNodeNumber = record.getIndex(); currentOffset = firstNodeOffset + (currentNodeNumber * currentNodeSize); - log.debug("Current node number: " + currentNodeNumber + " currentOffset:" + - currentOffset + "(" + currentNodeSize + ")"); + log.debug("Current node number: " + currentNodeNumber + " currentOffset:" + currentOffset + "(" + + currentNodeSize + ")"); nodeData = ByteBuffer.allocate(currentNodeSize); fs.getApi().read(currentOffset, nodeData); currentBtnd = new NodeDescriptor(nodeData.array()); @@ -74,8 +73,7 @@ } LeafRecord lr = null; if (currentBtnd.getKind() == HfsPlusConstants.BT_LEAF_NODE) { - CatalogLeafNode leaf = - new CatalogLeafNode(currentBtnd, nodeData.array(), currentNodeSize); + CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, nodeData.array(), currentNodeSize); lr = leaf.find(parentID); log.debug("Leaf record :\n" + lr.toString()); } @@ -99,8 +97,7 @@ * @return * @throws IOException */ - public final LeafRecord[] getRecords(final CatalogNodeId parentID, final int nodeNumber) - throws IOException { + public final LeafRecord[] getRecords(final CatalogNodeId parentID, final int nodeNumber) throws IOException { try { int currentOffset = firstNodeOffset; int currentNodeNumber = nodeNumber; @@ -110,8 +107,8 @@ NodeDescriptor currentBtnd = new NodeDescriptor(nodeData.array()); log.debug("Current node descriptor:\n" + currentBtnd.toString()); if (currentBtnd.getKind() == HfsPlusConstants.BT_INDEX_NODE) { - CatalogIndexNode currentIndexNode = - new CatalogIndexNode(currentBtnd, nodeData.array(), currentNodeSize); + CatalogIndexNode currentIndexNode = new CatalogIndexNode(currentBtnd, nodeData.array(), + currentNodeSize); IndexRecord[] records = currentIndexNode.findChilds(parentID); List<LeafRecord> lfList = new LinkedList<LeafRecord>(); for (IndexRecord rec : records) { @@ -122,8 +119,8 @@ } return lfList.toArray(new LeafRecord[lfList.size()]); } else if (currentBtnd.getKind() == HfsPlusConstants.BT_LEAF_NODE) { - CatalogLeafNode leaf = - new CatalogLeafNode(currentBtnd, nodeData.array(), currentNodeSize); + CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, nodeData.array(), + currentNodeSize); LeafRecord[] lr = leaf.findAll(parentID); log.debug("Leaf record size: " + lr.length); return lr; @@ -145,8 +142,8 @@ * @return * @throws IOException */ - public final LeafRecord getRecord(final CatalogNodeId parentID, final HFSUnicodeString nodeName) - throws IOException { + public final LeafRecord getRecord(final CatalogNodeId parentID, + final HFSUnicodeString nodeName) throws IOException { int currentOffset = firstNodeOffset; int currentNodeNumber = getBTHeaderRecord().getRootNode(); int currentNodeSize = getBTHeaderRecord().getNodeSize(); @@ -156,8 +153,7 @@ log.debug("Current node descriptor: \n" + currentBtnd.toString()); CatalogKey cKey = new CatalogKey(parentID, nodeName); while (currentBtnd.getKind() == HfsPlusConstants.BT_INDEX_NODE) { - CatalogIndexNode currentIndexNode = - new CatalogIndexNode(currentBtnd, buffer.array(), currentNodeSize); + CatalogIndexNode currentIndexNode = new CatalogIndexNode(currentBtnd, buffer.array(), currentNodeSize); IndexRecord record = currentIndexNode.find(cKey); currentNodeNumber = record.getIndex(); currentOffset = currentNodeNumber * currentNodeSize; @@ -167,8 +163,7 @@ } LeafRecord lr = null; if (currentBtnd.getKind() == HfsPlusConstants.BT_LEAF_NODE) { - CatalogLeafNode leaf = - new CatalogLeafNode(currentBtnd, buffer.array(), currentNodeSize); + CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, buffer.array(), currentNodeSize); lr = leaf.find(parentID); log.debug("Leaf record: \n" + lr.toString()); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -15,7 +15,7 @@ public final int getRecordType() { return BigEndian.getInt16(data, 0); } - + public final int getFlags() { return BigEndian.getInt16(data, 2); } @@ -23,17 +23,17 @@ public final CatalogNodeId getFileId() { return new CatalogNodeId(data, 8); } - + public final int getCreateDate() { - return BigEndian.getInt32(data, 12); + return BigEndian.getInt32(data, 12); } - + public final int getContentModDate() { - return BigEndian.getInt32(data, 16); + return BigEndian.getInt32(data, 16); } - + public final int getAttrModDate() { - return BigEndian.getInt32(data, 20); + return BigEndian.getInt32(data, 20); } public final HFSPlusForkData getDataFork() { @@ -49,8 +49,10 @@ s.append("Record type:").append(getRecordType()).append("\t"); s.append("File ID :").append(getFileId().getId()).append("\n"); s.append("Creation Date :").append(HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - s.append("Content Mod Date :").append(HFSUtils.printDate(getContentModDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - s.append("Attr Mod Date :").append(HFSUtils.printDate(getAttrModDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); + s.append("Content Mod Date :").append(HFSUtils.printDate(getContentModDate(), "EEE MMM d HH:mm:ss yyyy")) + .append("\n"); + s.append("Attr Mod Date :").append(HFSUtils.printDate(getAttrModDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n"); return s.toString(); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -11,18 +11,18 @@ data = new byte[88]; System.arraycopy(src, 0, data, 0, 88); } - + /** * Create a new catalog folder. * * @param folderId * */ - public CatalogFolder(CatalogNodeId folderId){ - data = new byte[88]; - BigEndian.setInt16(data, 0, HfsPlusConstants.RECORD_TYPE_FOLDER); - BigEndian.setInt32(data, 4, 0); - System.arraycopy(folderId.getBytes(), 0, data, 8, folderId.getBytes().length); + public CatalogFolder(CatalogNodeId folderId) { + data = new byte[88]; + BigEndian.setInt16(data, 0, HfsPlusConstants.RECORD_TYPE_FOLDER); + BigEndian.setInt32(data, 4, 0); + System.arraycopy(folderId.getBytes(), 0, data, 8, folderId.getBytes().length); } public final int getRecordType() { @@ -36,21 +36,21 @@ public final CatalogNodeId getFolderId() { return new CatalogNodeId(data, 8); } - + public final int getCreateDate() { - return BigEndian.getInt32(data, 12); + return BigEndian.getInt32(data, 12); } - + public final int getContentModDate() { - return BigEndian.getInt32(data, 16); + return BigEndian.getInt32(data, 16); } - + public final int getAttrModDate() { - return BigEndian.getInt32(data, 20); + return BigEndian.getInt32(data, 20); } - - public byte[] getBytes(){ - return data; + + public byte[] getBytes() { + return data; } public final String toString() { @@ -59,8 +59,10 @@ s.append("Valence: ").append(getValence()).append("\n"); s.append("Folder ID: ").append(getFolderId().getId()).append("\n"); s.append("Creation Date :").append(HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - s.append("Content Mod Date :").append(HFSUtils.printDate(getContentModDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); - s.append("Attr Mod Date :").append(HFSUtils.printDate(getAttrModDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); + s.append("Content Mod Date :").append(HFSUtils.printDate(getContentModDate(), "EEE MMM d HH:mm:ss yyyy")) + .append("\n"); + s.append("Attr Mod Date :").append(HFSUtils.printDate(getAttrModDate(), "EEE MMM d HH:mm:ss yyyy")).append( + "\n"); return s.toString(); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -11,8 +11,7 @@ public class CatalogIndexNode extends IndexNode { private final Logger log = Logger.getLogger(getClass()); - public CatalogIndexNode(final NodeDescriptor descriptor, final byte[] nodeData, - final int nodeSize) { + public CatalogIndexNode(final NodeDescriptor descriptor, final byte[] nodeData, final int nodeSize) { super(descriptor, nodeData, nodeSize); for (int i = 0; i < records.length; ++i) { int currentOffset = offsets[i]; @@ -45,8 +44,8 @@ CatalogKey largestMatchingKey = null; for (IndexRecord rec : records) { CatalogKey key = (CatalogKey) rec.getKey(); - if (key.getParentId().getId() < parentId.getId() && - (largestMatchingKey == null || key.compareTo(largestMatchingKey) > 0)) { + if (key.getParentId().getId() < parentId.getId() + && (largestMatchingKey == null || key.compareTo(largestMatchingKey) > 0)) { largestMatchingKey = key; largestMatchingRecord = rec; } else if (key.getParentId().getId() == parentId.getId()) { @@ -64,9 +63,9 @@ public final IndexRecord find(final CatalogKey key) { IndexRecord largestMatchingRecord = null; for (int i = 0; i < records.length; ++i) { - if (records[i].getKey().compareTo(key) <= 0 && - (largestMatchingRecord == null || records[i].getKey().compareTo( - largestMatchingRecord.getKey()) > 0)) { + if (records[i].getKey().compareTo(key) <= 0 + && (largestMatchingRecord == null || + records[i].getKey().compareTo(largestMatchingRecord.getKey()) > 0)) { largestMatchingRecord = records[i]; } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -73,8 +73,7 @@ StringBuffer s = new StringBuffer(); s.append("Key length: ").append(getKeyLength()).append(" "); s.append("Parent ID: ").append(getParentId().getId()).append(" "); - s.append("Node name: ").append( - (getNodeName() != null) ? getNodeName().getUnicodeString() : ""); + s.append("Node name: ").append((getNodeName() != null) ? getNodeName().getUnicodeString() : ""); return s.toString(); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -10,8 +10,7 @@ public class CatalogLeafNode extends LeafNode { - public CatalogLeafNode(final NodeDescriptor descriptor, final byte[] nodeData, - final int nodeSize) { + public CatalogLeafNode(final NodeDescriptor descriptor, final byte[] nodeData, final int nodeSize) { super(descriptor, nodeData, nodeSize); for (int i = 0; i < records.length; ++i) { int currentOffset = offsets[i]; @@ -47,8 +46,7 @@ List<LeafRecord> list = new LinkedList<LeafRecord>(); for (LeafRecord rec : records) { Key key = rec.getKey(); - if (key instanceof CatalogKey && - ((CatalogKey) key).getParentId().getId() == parentId.getId()) { + if (key instanceof CatalogKey && ((CatalogKey) key).getParentId().getId() == parentId.getId()) { list.add(rec); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNodeId.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNodeId.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNodeId.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -39,9 +39,9 @@ public final int getId() { return BigEndian.getInt32(cnid, 0); } - - public final byte[] getBytes(){ - return cnid; + + public final byte[] getBytes() { + return cnid; } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -18,13 +18,13 @@ * @param parent * @param name */ - public CatalogThread(int type, CatalogNodeId parent, HFSUnicodeString name){ - BigEndian.setInt16(data, 0, type); - BigEndian.setInt32(data, 4, parent.getId()); - System.arraycopy(parent.getBytes(), 0, data, 4, 4); - System.arraycopy(name.getBytes(), 0, data, 8, name.getBytes().length); + public CatalogThread(int type, CatalogNodeId parent, HFSUnicodeString name) { + BigEndian.setInt16(data, 0, type); + BigEndian.setInt32(data, 4, parent.getId()); + System.arraycopy(parent.getBytes(), 0, data, 4, 4); + System.arraycopy(name.getBytes(), 0, data, 8, name.getBytes().length); } - + public final int getRecordType() { return BigEndian.getInt16(data, 0); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -6,14 +6,14 @@ public class FormatHfsPlusCommand extends AbstractFormatCommand<HfsPlusFileSystem> { - public FormatHfsPlusCommand() { - super("Format a block device with HFS+ filesystem"); - } + public FormatHfsPlusCommand() { + super("Format a block device with HFS+ filesystem"); + } - @Override - protected Formatter<HfsPlusFileSystem> getFormatter() { - // TODO implement it. - return null; - } + @Override + protected Formatter<HfsPlusFileSystem> getFormatter() { + // TODO implement it. + return null; + } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -14,7 +14,7 @@ public ExtentDescriptor() { data = new byte[EXTENT_DESCRIPTOR_LENGTH]; } - + public ExtentDescriptor(final byte[] src, final int offset) { data = new byte[EXTENT_DESCRIPTOR_LENGTH]; System.arraycopy(src, offset, data, 0, EXTENT_DESCRIPTOR_LENGTH); @@ -24,22 +24,22 @@ return BigEndian.getInt32(data, 0); } - public final void setStartBlock(int start){ - BigEndian.setInt32(data, 0, start); + public final void setStartBlock(int start) { + BigEndian.setInt32(data, 0, start); } - + public final int getBlockCount() { return BigEndian.getInt32(data, 4); } - - public final void setBlockCount(int count){ - BigEndian.setInt32(data, 4, count); + + public final void setBlockCount(int count) { + BigEndian.setInt32(data, 4, count); } - public final byte[] getBytes(){ - return data; + public final byte[] getBytes() { + return data; } - + public final String toString() { return "Start block : " + getStartBlock() + "\tBlock count : " + getBlockCount() + "\n"; } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentIndexNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentIndexNode.java 2009-01-04 10:08:42 UTC (rev 4824) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentIndexNode.java 2009-01-04 11:42:26 UTC (rev 4825) @@ -6,8 +6,7 @@ import org.jnode.fs.hfsplus.tree.NodeDescriptor; public class ExtentIndexNode extends IndexNode { - public ExtentIndexNode(final NodeDescriptor descriptor, final byte[] nodeData, - final int nodeSize) { + public ExtentIndexNode(final NodeDescriptor descriptor, final byte[] nodeData, final int nodeSize) { super(descr... [truncated message content] |