actually apply FileSourceTransformations if specified
This commit is contained in:
parent
7fdf6e79a2
commit
0921852b48
@ -156,7 +156,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
|
||||
public byte[] GetData(long offset, long length)
|
||||
{
|
||||
if (mvarSource != null) return mvarSource.GetData(offset, length);
|
||||
if (mvarSource != null) return mvarSource.GetDataInternal(offset, length);
|
||||
|
||||
Console.WriteLine("DataRequest: " + mvarName + ": No source associated with this file");
|
||||
return new byte[length];
|
||||
@ -380,7 +380,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
|
||||
for (long i = 0; i < blockCount; i++)
|
||||
{
|
||||
byte[] data = mvarSource.GetData(offset, blockSize);
|
||||
byte[] data = mvarSource.GetDataInternal(offset, blockSize);
|
||||
offset += blockSize;
|
||||
|
||||
bw.WriteBytes(data);
|
||||
|
||||
@ -31,8 +31,20 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
public FileSourceTransformation.FileSourceTransformationCollection Transformations { get { return mvarTransformations; } }
|
||||
|
||||
public byte[] GetData() { return GetData(0, GetLength()); }
|
||||
public byte[] GetData(long offset, long length)
|
||||
{
|
||||
byte[] data = GetDataInternal(offset, length);
|
||||
System.IO.MemoryStream msInput = new System.IO.MemoryStream(data);
|
||||
for (int i = 0; i < Transformations.Count; i++)
|
||||
{
|
||||
System.IO.MemoryStream msOutput = new System.IO.MemoryStream();
|
||||
Transformations[i].Function(this, msInput, msOutput);
|
||||
msInput = msOutput;
|
||||
}
|
||||
return msInput.ToArray();
|
||||
}
|
||||
|
||||
public abstract byte[] GetData(long offset, long length);
|
||||
public abstract byte[] GetDataInternal(long offset, long length);
|
||||
public abstract long GetLength();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ namespace UniversalEditor.ObjectModels.FileSystem.FileSources
|
||||
mvarAccessor = accessor;
|
||||
}
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
mvarAccessor.Seek(offset, IO.SeekOrigin.Begin);
|
||||
byte[] data = mvarAccessor.Reader.ReadBytes(length);
|
||||
|
||||
@ -36,7 +36,7 @@ namespace UniversalEditor.ObjectModels.FileSystem.FileSources
|
||||
public long DecompressedLength { get; private set; }
|
||||
public long CompressedLength { get; private set; }
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
Reader.Seek(Offset, SeekOrigin.Begin);
|
||||
byte[] sourceData = Reader.ReadBytes(DecompressedLength);
|
||||
|
||||
@ -39,7 +39,7 @@ namespace UniversalEditor.ObjectModels.FileSystem.FileSources
|
||||
private long mvarLength = 0;
|
||||
public long Length { get { return mvarLength; } set { mvarLength = value; } }
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
mvarReader.Seek(mvarOffset, SeekOrigin.Begin);
|
||||
byte[] sourceData = mvarReader.ReadBytes(mvarLength);
|
||||
|
||||
@ -36,7 +36,7 @@ namespace UniversalEditor.ObjectModels.FileSystem.FileSources
|
||||
mvarData = data;
|
||||
}
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
long realLength = Math.Min(length, mvarData.Length);
|
||||
byte[] data = new byte[realLength];
|
||||
|
||||
@ -31,7 +31,7 @@ namespace UniversalEditor.ObjectModels.FileSystem.FileSources
|
||||
private string mvarFileName = String.Empty;
|
||||
public string FileName { get { return mvarFileName; } set { mvarFileName = value; } }
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
byte[] sourceData = System.IO.File.ReadAllBytes(mvarFileName);
|
||||
long realLength = Math.Min(length, sourceData.Length);
|
||||
|
||||
@ -45,7 +45,7 @@ namespace UniversalEditor.DataFormats.FileSystem.CHD
|
||||
HunkSize = hunkSize;
|
||||
}
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
return ReadHunk(Reader, HunkId, offset, length);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace UniversalEditor.DataFormats.FileSystem.HostileWaters
|
||||
|
||||
private Reader mbxReader = null;
|
||||
|
||||
public override byte[] GetData(long offset, long length)
|
||||
public override byte[] GetDataInternal(long offset, long length)
|
||||
{
|
||||
if (mbxReader == null)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user