Compare commits

..

6 Commits

Author SHA1 Message Date
Perfare c9394cd957 Fixed #734 2021-05-28 03:49:46 +08:00
Perfare 46c0e8ffe1 Improve stream file processing 2021-05-28 03:43:32 +08:00
Perfare d14c232015 Improve the error message 2021-05-28 03:27:50 +08:00
Perfare 4002bdecb8 Update README.md 2021-05-27 03:55:37 +08:00
StarHeart 17259e00c7 correct grammar (#749) 2021-05-27 03:49:40 +08:00
Perfare 44b02b92d8 fix lzma decompression 2021-05-27 03:46:15 +08:00
10 changed files with 62 additions and 32 deletions
+14 -13
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static AssetStudio.ImportHelper;
namespace AssetStudio
@@ -108,10 +109,10 @@ namespace AssetStudio
}
}
}
catch
catch (Exception e)
{
Logger.Error($"Error while reading assets file {fileName}", e);
reader.Dispose();
//Logger.Warning($"Unable to load assets file {fileName}");
}
}
else
@@ -136,9 +137,9 @@ namespace AssetStudio
assetsFileList.Add(assetsFile);
assetsFileListHash.Add(assetsFile.fileName);
}
catch
catch (Exception e)
{
//Logger.Error($"Unable to load assets file {fileName} from {Path.GetFileName(originalPath)}");
Logger.Error($"Error while reading assets file {fileName} from {Path.GetFileName(originalPath)}", e);
resourceFileReaders.Add(fileName, reader);
}
}
@@ -161,18 +162,18 @@ namespace AssetStudio
}
else
{
resourceFileReaders.Add(file.fileName, subReader);
resourceFileReaders[file.fileName] = subReader; //TODO
}
}
}
catch
catch (Exception e)
{
/*var str = $"Unable to load bundle file {fileName}";
var str = $"Error while reading bundle file {fileName}";
if (parentPath != null)
{
str += $" from {Path.GetFileName(parentPath)}";
}
Logger.Error(str);*/
Logger.Error(str, e);
}
finally
{
@@ -202,14 +203,14 @@ namespace AssetStudio
LoadWebFile(dummyPath, fileReader);
break;
case FileType.ResourceFile:
resourceFileReaders.Add(file.fileName, fileReader);
resourceFileReaders[file.fileName] = fileReader; //TODO
break;
}
}
}
catch
catch (Exception e)
{
//Logger.Error($"Unable to load web file {fileName}");
Logger.Error($"Error while reading web file {fileName}", e);
}
finally
{
@@ -344,13 +345,13 @@ namespace AssetStudio
}
catch (Exception e)
{
/*var sb = new StringBuilder();
var sb = new StringBuilder();
sb.AppendLine("Unable to load object")
.AppendLine($"Assets {assetsFile.fileName}")
.AppendLine($"Type {objectReader.type}")
.AppendLine($"PathID {objectInfo.m_PathID}")
.Append(e);
Logger.Error(sb.ToString());*/
Logger.Error(sb.ToString());
}
Progress.Report(++i, progressCount);
+4 -1
View File
@@ -171,6 +171,7 @@ namespace AssetStudio
var node = m_DirectoryInfo[i];
var file = new StreamFile();
fileList[i] = file;
file.path = node.path;
file.fileName = Path.GetFileName(node.path);
if (node.size >= int.MaxValue)
{
@@ -231,7 +232,9 @@ namespace AssetStudio
}
case 1: //LZMA
{
blocksInfoUncompresseddStream = SevenZipHelper.StreamDecompress(blocksInfoCompressedStream);
blocksInfoUncompresseddStream = new MemoryStream((int)(m_Header.uncompressedBlocksInfoSize));
SevenZipHelper.StreamDecompress(blocksInfoCompressedStream, blocksInfoUncompresseddStream, m_Header.compressedBlocksInfoSize, m_Header.uncompressedBlocksInfoSize);
blocksInfoUncompresseddStream.Position = 0;
blocksInfoCompressedStream.Close();
break;
}
+8
View File
@@ -14,5 +14,13 @@ namespace AssetStudio
public static void Info(string message) => Default.Log(LoggerEvent.Info, message);
public static void Warning(string message) => Default.Log(LoggerEvent.Warning, message);
public static void Error(string message) => Default.Log(LoggerEvent.Error, message);
public static void Error(string message, Exception e)
{
var sb = new StringBuilder();
sb.AppendLine(message);
sb.AppendLine(e.ToString());
Default.Log(LoggerEvent.Error, sb.ToString());
}
}
}
+5 -4
View File
@@ -34,15 +34,16 @@ namespace AssetStudio
return newOutStream;
}
public static void StreamDecompress(Stream inStream, Stream outStream, long inSize, long outSize)
public static void StreamDecompress(Stream compressedStream, Stream decompressedStream, long compressedSize, long decompressedSize)
{
var basePosition = compressedStream.Position;
var decoder = new Decoder();
var properties = new byte[5];
if (inStream.Read(properties, 0, 5) != 5)
if (compressedStream.Read(properties, 0, 5) != 5)
throw new Exception("input .lzma is too short");
decoder.SetDecoderProperties(properties);
inSize -= 5L;
decoder.Code(inStream, outStream, inSize, outSize, null);
decoder.Code(compressedStream, decompressedStream, compressedSize - 5, decompressedSize, null);
compressedStream.Position = basePosition + compressedSize;
}
}
}
+1
View File
@@ -4,6 +4,7 @@ namespace AssetStudio
{
public class StreamFile
{
public string path;
public string fileName;
public Stream stream;
}
+2 -2
View File
@@ -17,7 +17,7 @@ namespace AssetStudio
var readed = reader.Position - reader.byteStart;
if (readed != reader.byteSize)
{
Logger.Error($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
Logger.Info($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
}
}
@@ -169,7 +169,7 @@ namespace AssetStudio
var readed = reader.Position - reader.byteStart;
if (readed != reader.byteSize)
{
Logger.Error($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
Logger.Info($"Error while read type, read {readed} bytes but expected {reader.byteSize} bytes");
}
return obj;
}
+1
View File
@@ -83,6 +83,7 @@ namespace AssetStudio
{
var data = dataList[i];
var file = new StreamFile();
file.path = data.path;
file.fileName = Path.GetFileName(data.path);
reader.BaseStream.Position = data.dataOffset;
file.stream = new MemoryStream(reader.ReadBytes(data.dataLength));
+13 -6
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AssetStudio;
using AssetStudio;
using System;
using System.Windows.Forms;
namespace AssetStudioGUI
{
@@ -17,7 +15,16 @@ namespace AssetStudioGUI
public void Log(LoggerEvent loggerEvent, string message)
{
action(message);
switch (loggerEvent)
{
case LoggerEvent.Error:
MessageBox.Show(message);
break;
default:
action(message);
break;
}
}
}
}
+12 -4
View File
@@ -113,10 +113,11 @@ namespace AssetStudioGUI
int extractedCount = 0;
foreach (var file in fileList)
{
var filePath = Path.Combine(extractPath, file.fileName);
if (!Directory.Exists(extractPath))
var filePath = Path.Combine(extractPath, file.path);
var fileDirectory = Path.GetDirectoryName(filePath);
if (!Directory.Exists(fileDirectory))
{
Directory.CreateDirectory(extractPath);
Directory.CreateDirectory(fileDirectory);
}
if (!File.Exists(filePath))
{
@@ -398,7 +399,14 @@ namespace AssetStudioGUI
}
break;
case 2: //source file
exportPath = Path.Combine(savePath, asset.SourceFile.fullName + "_export");
if (string.IsNullOrEmpty(asset.SourceFile.originalPath))
{
exportPath = Path.Combine(savePath, asset.SourceFile.fileName + "_export");
}
else
{
exportPath = Path.Combine(savePath, Path.GetFileName(asset.SourceFile.originalPath) + "_export", asset.SourceFile.fileName);
}
break;
default:
exportPath = savePath;
+2 -2
View File
@@ -7,7 +7,7 @@ AssetStudio is a tool for exploring, extracting and exporting assets and assetbu
## Features
* Support version:
* 2.5 - 2020.2
* 2.5 - 2021.1
* Support asset types:
* **Texture2D** : convert to png, tga, jpeg, bmp
* **Sprite** : crop Texture2D to png, tga, jpeg, bmp
@@ -59,7 +59,7 @@ When you select an asset of the MonoBehaviour type for the first time, AssetStud
#### For Il2Cpp
First, use my other program [Il2CppDumper](https://github.com/Perfare/Il2CppDumper) to generate dummy dll, then when using AssetStudio to select the assembly directory, select the dummy dll folder.
First, use my another program [Il2CppDumper](https://github.com/Perfare/Il2CppDumper) to generate dummy dll, then when using AssetStudio to select the assembly directory, select the dummy dll folder.
## Build