Revision: 5968 http://jnode.svn.sourceforge.net/jnode/?rev=5968&view=rev Author: galatnm Date: 2013-02-20 12:01:01 +0000 (Wed, 20 Feb 2013) Log Message: ----------- Better implementation of mapVcnToLcn() for compressed data runs. (Luke Quinane)
Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java 2013-02-20 11:56:05 UTC (rev 5967) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java 2013-02-20 12:01:01 UTC (rev 5968) @@ -224,7 +224,19 @@ @Override public long mapVcnToLcn(long vcn) { - return compressedRun.mapVcnToLcn(vcn); + // This is the actual number of stored clusters after compression. + // If the number of stored clusters is the same as the compression unit size, + // then the data can be read directly without decompressing it. + final int compClusters = compressedRun.getLength(); + if (compClusters == compressionUnitSize) { + return compressedRun.mapVcnToLcn(vcn); + } + + // Now we know the data is compressed. Map the VCN to the corresponding compressed block... + final long actFirstVcn = Math.max(compressedRun.getFirstVcn(), vcn); + final int vcnOffsetWithinUnit = (int) (actFirstVcn % compressionUnitSize); + final long compFirstVcn = actFirstVcn - vcnOffsetWithinUnit; + return compressedRun.mapVcnToLcn(compFirstVcn); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits