Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/IcySon55/Kuriimu
Browse files Browse the repository at this point in the history
  • Loading branch information
IcySon55 committed Aug 21, 2017
2 parents f5f6f8d + 8cd31fb commit df869b8
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/archive/archive_cdar/CdarSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public override Stream FileData
{
get
{
if (State != ArchiveFileState.Archived) return base.FileData;
if (State != ArchiveFileState.Archived || entry.decompSize == 0) return base.FileData;
return new MemoryStream(ZLib.Decompress(base.FileData));
}
}

public override long? FileSize => entry.decompSize;
public override long? FileSize => (entry.decompSize == 0) ? entry.compSize : entry.decompSize;

public void Write(Stream input, uint offset)
{
Expand All @@ -35,13 +35,24 @@ public void Write(Stream input, uint offset)
}
else
{
entry.offset = offset;
entry.decompSize = (uint)base.FileData.Length;
var comp = ZLib.Compress(base.FileData);
entry.compSize = (uint)comp.Length;
bw.Write(comp);
if (entry.decompSize == 0)
{
entry.offset = offset;
entry.compSize = (uint)base.FileData.Length;
base.FileData.CopyTo(bw.BaseStream);

bw.WriteAlignment();
bw.WriteAlignment();
}
else
{
entry.offset = offset;
entry.decompSize = (uint)base.FileData.Length;
var comp = ZLib.Compress(base.FileData);
entry.compSize = (uint)comp.Length;
bw.Write(comp);

bw.WriteAlignment();
}
}
}
}
Expand Down

0 comments on commit df869b8

Please sign in to comment.