crc/whirlpool for archives
This commit is contained in:
@@ -55,7 +55,7 @@ public class Archive
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Arrays.equals(this.whirlpool, other.whirlpool))
|
if (this.whirlpool != null && other.whirlpool != null && !Arrays.equals(this.whirlpool, other.whirlpool))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ public class DataFile implements Closeable
|
|||||||
int sector;
|
int sector;
|
||||||
int startSector;
|
int startSector;
|
||||||
|
|
||||||
data = ByteBuffer.wrap(this.compress(data.array(), compression, revision));
|
byte[] compressedData = this.compress(data.array(), compression, revision);
|
||||||
int dataLen = data.remaining();
|
data = ByteBuffer.wrap(compressedData);
|
||||||
|
|
||||||
//XTEA encrypt here?
|
//XTEA encrypt here?
|
||||||
|
|
||||||
@@ -270,7 +270,9 @@ public class DataFile implements Closeable
|
|||||||
|
|
||||||
DataFileWriteResult res = new DataFileWriteResult();
|
DataFileWriteResult res = new DataFileWriteResult();
|
||||||
res.sector = startSector;
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,6 @@ package net.runelite.cache.fs;
|
|||||||
public class DataFileWriteResult
|
public class DataFileWriteResult
|
||||||
{
|
{
|
||||||
public int sector, compressedLength;
|
public int sector, compressedLength;
|
||||||
|
public int crc; // crc of compressed data
|
||||||
|
public byte[] whirlpool;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,6 +351,9 @@ public class Index implements Closeable
|
|||||||
// XXX old data is just left there in the file?
|
// XXX old data is just left there in the file?
|
||||||
DataFileWriteResult res = data.write(this.id, a.getArchiveId(), ByteBuffer.wrap(fileData), 0, this.revision);
|
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));
|
this.index.write(new IndexEntry(this.index, a.getArchiveId(), res.sector, res.compressedLength));
|
||||||
|
|
||||||
|
a.setCrc(res.crc);
|
||||||
|
a.setWhirlpool(res.whirlpool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user