public static MainPacket Create(PacketHeader header, byte[] bytes, int index) { MainPacket tmpPacket = new MainPacket(); tmpPacket.header = header; int offset = 0; tmpPacket.blocksize = BitConverter.ToUInt64(bytes, index + offset); offset += sizeof(UInt64); tmpPacket.recoverablefilecount = BitConverter.ToUInt32(bytes, index + offset); offset += sizeof(UInt32); tmpPacket.totalfilecount = ((uint)header.length - ((uint)header.GetSize() + sizeof(UInt64) + sizeof(UInt32))) / (16 * sizeof(byte)); for (int i = 0; i < tmpPacket.totalfilecount; i++) { byte[] fileid = new byte[16]; Buffer.BlockCopy(bytes, index + offset, fileid, 0, fileid.Length * sizeof(byte)); offset += fileid.Length * sizeof(byte); tmpPacket.fileids.Add(fileid); } System.Threading.Tasks.Task.Factory.StartNew((b) => { //FastCRC32.FastCRC32 crc32 = new FastCRC32.FastCRC32((ulong)b); FastCRC32.FastCRC32 crc32 = FastCRC32.FastCRC32.GetCRC32Instance((ulong)b); }, tmpPacket.blocksize); return tmpPacket; }
public static MainPacket Create(PacketHeader header, byte[] bytes, int index) { MainPacket tmpPacket = new MainPacket(); tmpPacket.header = header; int offset = 0; tmpPacket.blocksize = BitConverter.ToUInt64(bytes, index + offset); offset += sizeof(UInt64); tmpPacket.recoverablefilecount = BitConverter.ToUInt32(bytes, index + offset); offset += sizeof(UInt32); tmpPacket.totalfilecount = ((uint)header.length - ((uint)header.GetSize() + sizeof(UInt64) + sizeof(UInt32))) / (16 * sizeof(byte)); for (int i = 0; i < tmpPacket.totalfilecount; i++) { byte[] fileid = new byte[16]; Buffer.BlockCopy(bytes, index + offset, fileid, 0, fileid.Length * sizeof(byte)); offset += fileid.Length * sizeof(byte); tmpPacket.fileids.Add(fileid); } System.Threading.Tasks.Task.Factory.StartNew((b) => { //FastCRC32.FastCRC32 crc32 = new FastCRC32.FastCRC32((ulong)b); FastCRC32.FastCRC32 crc32 = FastCRC32.FastCRC32.GetCRC32Instance((ulong)b); }, tmpPacket.blocksize); return(tmpPacket); }
public static MainPacket Create(Par2LibraryArguments args) { MainPacket tmpPacket = new MainPacket(); tmpPacket.header = new PacketHeader(); tmpPacket.header.setid = new byte[16]; tmpPacket.header.magic = Par2FileReader.packet_magic; tmpPacket.header.type = Par2FileReader.mainpacket_type; tmpPacket.blocksize = (ulong)args.blocksize; tmpPacket.recoverablefilecount = (uint)args.inputFiles.Length; tmpPacket.fileids = new List<byte[]>(); tmpPacket.header.length = (ulong)(tmpPacket.GetSize() + (16 * sizeof(byte) * args.inputFiles.Length)); // setid calculation and fileids insertion will occur in Par2RecoverySet.OpenSourceFiles method System.Threading.Tasks.Task.Factory.StartNew((b) => { //FastCRC32.FastCRC32 crc32 = new FastCRC32.FastCRC32((ulong)b); FastCRC32.FastCRC32 crc32 = FastCRC32.FastCRC32.GetCRC32Instance((ulong)b); }, tmpPacket.blocksize); return tmpPacket; }
public static MainPacket Create(Par2LibraryArguments args) { MainPacket tmpPacket = new MainPacket(); tmpPacket.header = new PacketHeader(); tmpPacket.header.setid = new byte[16]; tmpPacket.header.magic = Par2FileReader.packet_magic; tmpPacket.header.type = Par2FileReader.mainpacket_type; tmpPacket.blocksize = (ulong)args.blocksize; tmpPacket.recoverablefilecount = (uint)args.inputFiles.Length; tmpPacket.fileids = new List <byte[]>(); tmpPacket.header.length = (ulong)(tmpPacket.GetSize() + (16 * sizeof(byte) * args.inputFiles.Length)); // setid calculation and fileids insertion will occur in Par2RecoverySet.OpenSourceFiles method System.Threading.Tasks.Task.Factory.StartNew((b) => { //FastCRC32.FastCRC32 crc32 = new FastCRC32.FastCRC32((ulong)b); FastCRC32.FastCRC32 crc32 = FastCRC32.FastCRC32.GetCRC32Instance((ulong)b); }, tmpPacket.blocksize); return(tmpPacket); }