Extract fileList to a separate class

This commit is contained in:
VaDiM
2026-03-02 17:21:34 +03:00
parent 1856378377
commit 0a381aff55
6 changed files with 41 additions and 35 deletions
+2 -2
View File
@@ -360,7 +360,7 @@ namespace AssetStudio
private bool LoadBundleFiles(FileReader reader, BundleFile bundleFile, string originalPath = null)
{
foreach (var file in bundleFile.fileList)
foreach (var file in bundleFile.FileList)
{
if (file.stream == null)
continue;
@@ -386,7 +386,7 @@ namespace AssetStudio
try
{
var webFile = new WebFile(reader);
foreach (var file in webFile.fileList)
foreach (var file in webFile.FileList)
{
var dummyPath = Path.Combine(Path.GetDirectoryName(reader.FullPath), file.fileName);
var subReader = new FileReader(dummyPath, file.stream);
+2 -6
View File
@@ -1,6 +1,5 @@
using AssetStudio.CustomOptions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -42,7 +41,7 @@ namespace AssetStudio
Oodle, //custom
}
public class BundleFile
public class BundleFile : FileArchive
{
public readonly bool IsDataAfterBundle;
private static TempFileStream _sharedTempFileStream;
@@ -79,8 +78,6 @@ namespace AssetStudio
private StorageBlock[] m_BlocksInfo;
private Node[] m_DirectoryInfo;
public List<StreamFile> fileList;
public BundleFile(FileReader reader, ImportOptions importOptions, bool isMultiBundle = false)
{
_bundleOptions = importOptions.BundleOptions;
@@ -240,11 +237,10 @@ namespace AssetStudio
private void ReadFiles(Stream inputStream, long blocksOffset = 0)
{
fileList = new List<StreamFile>(m_DirectoryInfo.Length);
foreach (var node in m_DirectoryInfo)
{
var file = new StreamFile();
fileList.Add(file);
this.FileList.Add(file);
file.path = node.path;
file.fileName = Path.GetFileName(node.path);
try
+9
View File
@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace AssetStudio
{
public abstract class FileArchive
{
public readonly List<StreamFile> FileList = new List<StreamFile>();
}
}
+2 -5
View File
@@ -4,10 +4,8 @@ using System.Text;
namespace AssetStudio
{
public class WebFile
public class WebFile : FileArchive
{
public List<StreamFile> fileList;
private class WebData
{
public int dataOffset;
@@ -30,15 +28,14 @@ namespace AssetStudio
data.path = Encoding.UTF8.GetString(reader.ReadBytes(pathLength));
dataList.Add(data);
}
fileList = new List<StreamFile>(dataList.Count);
foreach (var data in dataList)
{
var file = new StreamFile();
this.FileList.Add(file);
file.path = data.path;
file.fileName = Path.GetFileName(data.path);
reader.BaseStream.Position = data.dataOffset;
file.stream = new MemoryStream(reader.ReadBytes(data.dataLength));
fileList.Add(file);
}
}
}