mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-14 11:18:47 -05:00
Extract fileList to a separate class
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public abstract class FileArchive
|
||||
{
|
||||
public readonly List<StreamFile> FileList = new List<StreamFile>();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user