crc/whirlpool for archives

This commit is contained in:
Adam
2015-10-17 20:35:37 -04:00
parent eee5f72d4e
commit 4938226071
4 changed files with 11 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ public class Archive
{
return false;
}
if (!Arrays.equals(this.whirlpool, other.whirlpool))
if (this.whirlpool != null && other.whirlpool != null && !Arrays.equals(this.whirlpool, other.whirlpool))
{
return false;
}

View File

@@ -180,8 +180,8 @@ public class DataFile implements Closeable
int sector;
int startSector;
data = ByteBuffer.wrap(this.compress(data.array(), compression, revision));
int dataLen = data.remaining();
byte[] compressedData = this.compress(data.array(), compression, revision);
data = ByteBuffer.wrap(compressedData);
//XTEA encrypt here?
@@ -270,7 +270,9 @@ public class DataFile implements Closeable
DataFileWriteResult res = new DataFileWriteResult();
res.sector = startSector;
res.compressedLength = dataLen;
res.compressedLength = compressedData.length;
res.crc = CRC32HGenerator.getHash(compressedData, compressedData.length - 2);
res.whirlpool = Whirlpool.getHash(compressedData, 0, compressedData.length - 2);
return res;
}

View File

@@ -3,4 +3,6 @@ package net.runelite.cache.fs;
public class DataFileWriteResult
{
public int sector, compressedLength;
public int crc; // crc of compressed data
public byte[] whirlpool;
}

View File

@@ -351,6 +351,9 @@ public class Index implements Closeable
// XXX old data is just left there in the file?
DataFileWriteResult res = data.write(this.id, a.getArchiveId(), ByteBuffer.wrap(fileData), 0, this.revision);
this.index.write(new IndexEntry(this.index, a.getArchiveId(), res.sector, res.compressedLength));
a.setCrc(res.crc);
a.setWhirlpool(res.whirlpool);
}
}