Skip to content

Commit

Permalink
temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AXiX-official committed Jul 17, 2024
1 parent c898b35 commit 3a4a307
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions UnityAsset.NET/BundleFile/BundleFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,30 @@ public sealed class BundleFile

private ArchiveFlags mask { get; set; }

public BundleFile(string path, bool original = false, string? key = null)
: this(new FileStream(path, FileMode.Open, FileAccess.Read), original, key)
public BundleFile(string path, string? key = null)
: this(new FileStream(path, FileMode.Open, FileAccess.Read), key)
{
}

public BundleFile(Stream input, bool original = false, string? key = null)
public BundleFile(Stream input, string? key = null)
{
using AssetReader reader = new AssetReader(input);

UnityCNKey = key;

Header = new Header(reader);
ReadBundleWithHeader(reader, Header, key);
}

public BundleFile(AssetReader reader,Header header, string? key = null)
{
UnityCNKey = key;
Header = header;
ReadBundleWithHeader(reader, header, key);
}

private void ReadBundleWithHeader(AssetReader reader, Header header, string? key = null)
{
var version = ParseVersion();

if (version[0] < 2020 || //2020 and earlier
Expand Down
7 changes: 7 additions & 0 deletions UnityAsset.NET/IO/AssetReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public AssetReader(Stream stream, bool isBigEndian = true) : base(stream)
StartPosition = stream.Position;
}

public AssetReader(string filePath, bool isBigEndian = true) : base(new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
buffer = new byte[8];
BigEndian = isBigEndian;
StartPosition = 0;
}

public void AlignStream(int alignment)
{
var pos = Position;
Expand Down

0 comments on commit 3a4a307

Please sign in to comment.