Skip to content

Commit ae2ebe5

Browse files
committed
feat: leaveOpen flag for bundle reading
1 parent b2002fe commit ae2ebe5

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

AssetTools.NET/Extra/AssetsManager/AssetsManager.Bundle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public partial class AssetsManager
1414
/// <param name="path">The path to set on the <see cref="AssetsFileInstance"/>.</param>
1515
/// <param name="unpackIfPacked">Unpack the bundle if it's compressed?</param>
1616
/// <returns>The loaded <see cref="BundleFileInstance"/>.</returns>
17-
public BundleFileInstance LoadBundleFile(Stream stream, string path, bool unpackIfPacked = true)
17+
public BundleFileInstance LoadBundleFile(Stream stream, string path, bool unpackIfPacked = true, bool leaveOpen = false)
1818
{
1919
BundleFileInstance bunInst;
2020
string lookupKey = GetFileLookupKey(path);
2121
if (BundleLookup.TryGetValue(lookupKey, out bunInst))
2222
return bunInst;
2323

24-
bunInst = new BundleFileInstance(stream, path, unpackIfPacked);
24+
bunInst = new BundleFileInstance(stream, path, unpackIfPacked, leaveOpen);
2525
lock (BundleLookup)
2626
{
2727
lock (Bundles)

AssetTools.NET/Extra/AssetsManager/BundleFileInstance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public class BundleFileInstance
2020
public Stream BundleStream => file.Reader.BaseStream;
2121
public Stream DataStream => file.DataReader.BaseStream;
2222

23-
public BundleFileInstance(Stream stream, string filePath, bool unpackIfPacked = true)
23+
public BundleFileInstance(Stream stream, string filePath, bool unpackIfPacked = true, bool leaveOpen = false)
2424
{
2525
path = Path.GetFullPath(filePath);
2626
name = Path.GetFileName(path);
2727
file = new AssetBundleFile();
28-
file.Read(new AssetsFileReader(stream));
28+
file.Read(new AssetsFileReader(stream, leaveOpen));
2929
if (file.Header != null && file.DataIsCompressed && unpackIfPacked)
3030
{
3131
file = BundleHelper.UnpackBundle(file);

0 commit comments

Comments
 (0)