From 328793c5e332d879e7f8e14dc9922099f1c0dd8d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 8 May 2024 18:30:30 +0200 Subject: ChunkList: Add writeCrc32List method --- .../java/org/openslx/filetransfer/util/ChunkList.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/org/openslx/filetransfer') diff --git a/src/main/java/org/openslx/filetransfer/util/ChunkList.java b/src/main/java/org/openslx/filetransfer/util/ChunkList.java index bd927b1..4944847 100644 --- a/src/main/java/org/openslx/filetransfer/util/ChunkList.java +++ b/src/main/java/org/openslx/filetransfer/util/ChunkList.java @@ -1,5 +1,6 @@ package org.openslx.filetransfer.util; +import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -521,4 +522,21 @@ public class ChunkList return chunk.sha1sum != null && Arrays.equals( FileChunk.NULL_BLOCK_SHA1, chunk.sha1sum ); } + /** + * Write DNBD3 CRC32 list to given file. + * + * @throws IllegalStateException + * @throws IOException + */ + public void writeCrc32List( String crcfile ) throws IllegalStateException, IOException + { + byte[] dnbd3Crc32List = null; + dnbd3Crc32List = getDnbd3Crc32List(); + if ( dnbd3Crc32List != null ) { + try ( FileOutputStream fos = new FileOutputStream( crcfile ) ) { + fos.write( dnbd3Crc32List ); + } + } + } + } -- cgit v1.2.3-55-g7522