summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/util/CrcFile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/util/CrcFile.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/util/CrcFile.java53
1 files changed, 0 insertions, 53 deletions
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;
- }
-}