This commit is contained in:
Perfare 2018-08-30 21:34:41 +08:00
parent 2fd2b71148
commit 10f02af70b
2 changed files with 10 additions and 12 deletions

View File

@ -2,7 +2,6 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Lz4; using Lz4;
using SevenZip.Compression.LZMA;
namespace AssetStudio namespace AssetStudio
{ {
@ -229,7 +228,7 @@ namespace AssetStudio
file.stream = memoryMappedFile.CreateViewStream();*/ file.stream = memoryMappedFile.CreateViewStream();*/
var extractPath = path + "_unpacked\\"; var extractPath = path + "_unpacked\\";
Directory.CreateDirectory(extractPath); Directory.CreateDirectory(extractPath);
file.stream = new FileStream(extractPath + file.fileName, FileMode.Create); file.stream = File.Create(extractPath + file.fileName);
} }
else else
{ {

View File

@ -12,6 +12,13 @@ namespace AssetStudio
public static byte[] GetData(string path, string sourceFilePath, long offset, int size) public static byte[] GetData(string path, string sourceFilePath, long offset, int size)
{ {
var resourceFileName = Path.GetFileName(path); var resourceFileName = Path.GetFileName(path);
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var reader))
{
reader.Position = offset;
return reader.ReadBytes(size);
}
var resourceFilePath = Path.GetDirectoryName(sourceFilePath) + "\\" + resourceFileName; var resourceFilePath = Path.GetDirectoryName(sourceFilePath) + "\\" + resourceFileName;
if (!File.Exists(resourceFilePath)) if (!File.Exists(resourceFilePath))
{ {
@ -30,18 +37,10 @@ namespace AssetStudio
} }
} }
else else
{
if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
{
resourceReader.Position = offset;
return resourceReader.ReadBytes(size);
}
else
{ {
MessageBox.Show($"can't find the resource file {resourceFileName}"); MessageBox.Show($"can't find the resource file {resourceFileName}");
return null; return null;
} }
} }
} }
}
} }