From 6285288e0d5df6097012cd4af3dea3aaf1b8a869 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 18 Aug 2014 12:28:02 +0200 Subject: CRCFile -> CrcFile --- .../org/openslx/satellitedaemon/util/CrcFile.java | 53 ---------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/main/java/org/openslx/satellitedaemon/util/CrcFile.java (limited to 'src/main/java/org/openslx/satellitedaemon/util') diff --git a/src/main/java/org/openslx/satellitedaemon/util/CrcFile.java b/src/main/java/org/openslx/satellitedaemon/util/CrcFile.java deleted file mode 100644 index 59679d3..0000000 --- a/src/main/java/org/openslx/satellitedaemon/util/CrcFile.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.openslx.satellitedaemon.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.zip.CRC32; - -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Logger; - -// TODO: Merge with code/classes from masterser and put into master-sync-shared - -public class CrcFile -{ - private static Logger log = Logger.getLogger( CrcFile.class ); - public static void make( String path ) throws IOException - { - int blockSize = 16 * 1024 * 1024; - InputStream is = new FileInputStream( path ); - CRC32 crc = new CRC32(); - int cnt; - byte[] block = new byte[blockSize]; - byte[] WriteToFile = new byte[0]; - log.info( "Inputfile: " + path ); - while ( ( cnt = is.read(block) ) != -1 ) { - crc.update( cnt ); - log.info( "CRC value: " + crc.getValue() ); - byte[] latest = ByteBuffer.allocate(8).putLong(crc.getValue()).array(); - WriteToFile = concatenateByteArrays( WriteToFile, latest ); - } - String outPath = path.substring( 0, (path.length() - 4) ).concat( "crc" ); - File outFile = new File(outPath); - FileOutputStream fos = new FileOutputStream( outFile ); - fos.write( WriteToFile ); - is.close(); - fos.close(); - } - - public static void main( String[] args ) throws IOException { - BasicConfigurator.configure(); - CrcFile.make( "/tmp/test.vmdk"); - } - - public static byte[] concatenateByteArrays(byte[] a, byte[] b) { - byte[] result = new byte[a.length + b.length]; - System.arraycopy(a, 0, result, 0, a.length); - System.arraycopy(b, 0, result, a.length, b.length); - return result; - } -} -- cgit v1.2.3-55-g7522