Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Fix bundle saving
Browse files Browse the repository at this point in the history
  • Loading branch information
aianlinb committed Apr 23, 2021
1 parent 41c2c42 commit 32da28b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LibBundle/LibBundle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<Authors>aianlinb</Authors>
<Copyright>Copyright © 2020-2021 aianlinb.</Copyright>
<AssemblyVersion>2.4.4.0</AssemblyVersion>
<AssemblyVersion>2.4.6.0</AssemblyVersion>
<Platforms>x64</Platforms>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion LibBundle/Records/BundleRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public virtual void SaveWithRecompression(string newPath = null, string original
if (newPath == null && originalPath == null && Bundle.path == null)
throw new ArgumentNullException();
var data = Bundle.Read(originalPath);
data.SetLength(validSize);
data.Position = validSize;
foreach (var d in FileToAdd) {
d.Key.Offset = (int)data.Position;
data.Write(d.Value, 0, d.Key.Size);
Expand All @@ -120,11 +122,12 @@ public virtual byte[] SaveWithRecompression(BinaryReader br, long? Offset = null
Read(br, Offset);
var data = Bundle.Read(br);
data.SetLength(validSize);
data.Position = validSize;
foreach (var (f, b) in FileToAdd) {
f.Offset = (int)data.Position;
data.Write(b, 0, f.Size);
}
UncompressedSize = (int)data.Length;
UncompressedSize = validSize = (int)data.Length;
var result = Bundle.Save(data);
FileToAdd.Clear();
data.Close();
Expand Down

0 comments on commit 32da28b

Please sign in to comment.