public byte[] ReadFile(StoreFile file)
{
if(file == null) {
throw new ArgumentNullException("file");
}
// check if there is anything to read
if(file.Data == null) {
return null;
}
byte[] data = file.Data;
if((file.StoreMode & StoreMode.Encrypted) == StoreMode.Encrypted) {
data = DecryptData(data);
}
if((file.StoreMode & StoreMode.Compressed) == StoreMode.Compressed) {
data = DecompressData(data);
}
if(data.Length > file.RealSize) {
byte[] buffer = new byte[file.RealSize];
Buffer.BlockCopy(data, 0, buffer, 0, (int)file.RealSize);
return buffer;
}
return data;
}