Some minor fixes

This commit is contained in:
VaDiM
2025-05-11 17:57:33 +03:00
parent b0a051fc47
commit 55406553f6
17 changed files with 84 additions and 57 deletions

View File

@@ -91,9 +91,7 @@ namespace AssetStudio
public void LoadFilesAndFolders(params string[] path)
{
var pathList = new List<string>();
pathList.AddRange(path);
LoadFilesAndFolders(out _, pathList);
LoadFilesAndFolders(out _, path);
}
public void LoadFilesAndFolders(out string parentPath, params string[] path)
@@ -106,15 +104,15 @@ namespace AssetStudio
public void LoadFilesAndFolders(out string parentPath, List<string> pathList)
{
var fileList = new List<string>();
bool filesInPath = false;
var filesInPath = false;
parentPath = "";
foreach (var path in pathList)
{
var fullPath = Path.GetFullPath(path);
if (Directory.Exists(fullPath))
{
var parent = Directory.GetParent(fullPath).FullName;
if (!filesInPath && (parentPath == "" || parentPath.Length > parent.Length))
var parent = Directory.GetParent(fullPath)?.FullName;
if (!filesInPath && (parentPath == "" || parentPath?.Length > parent?.Length))
{
parentPath = parent;
}
@@ -241,6 +239,7 @@ namespace AssetStudio
else
{
noexistFiles.Add(sharedFilePath);
Logger.Warning($"Dependency wasn't found: {sharedFilePath}");
}
}
}

View File

@@ -399,6 +399,8 @@ namespace AssetStudio
private void ReadBlocks(FileReader reader, CompressionType customBlockCompression, Stream blocksStream)
{
Logger.Debug($"Block compression: {(CompressionType)m_BlocksInfo.Max(x => x.flags)}");
var showCustomTypeWarning = true;
foreach (var blockInfo in m_BlocksInfo)
{
@@ -420,7 +422,6 @@ namespace AssetStudio
showCustomTypeWarning = false;
}
}
Logger.Debug($"Block compression: {compressionType}");
long numWrite;
var errorMsg = string.Empty;

View File

@@ -115,7 +115,7 @@ namespace AssetStudio
{1138, "m_PrefabAsset"},
{1152, "FileSize"},
{1161, "Hash128"},
{1169, "RenderingLayerMask"},
{1169, "RenderingLayerMask"},
};
}
}

View File

@@ -68,7 +68,7 @@ namespace AssetStudio
}
catch (System.Exception e)
{
Logger.Warning($"Error while decompressing gzip file {reader.FullPath}\r\n{e}");
Logger.Warning($"Error while decompressing Gzip file {reader.FullPath}\n{e}");
reader.Dispose();
return null;
}
@@ -76,15 +76,24 @@ namespace AssetStudio
public static FileReader DecompressBrotli(FileReader reader)
{
using (reader)
try
{
var stream = new MemoryStream();
using (var brotliStream = new BrotliInputStream(reader.BaseStream))
using (reader)
{
brotliStream.CopyTo(stream);
var stream = new MemoryStream();
using (var brotliStream = new BrotliInputStream(reader.BaseStream))
{
brotliStream.CopyTo(stream);
}
stream.Position = 0;
return new FileReader(reader.FullPath, stream);
}
stream.Position = 0;
return new FileReader(reader.FullPath, stream);
}
catch (System.Exception e)
{
Logger.Warning($"Error while decompressing Brotli file {reader.FullPath}\n{e}");
reader.Dispose();
return null;
}
}
}

View File

@@ -84,15 +84,16 @@ namespace AssetStudio
}
}
public void GetData(byte[] buff, out int read, int startIndex = 0)
public int GetData(byte[] buff, int startIndex = 0)
{
read = -1;
int dataLen;
var binaryReader = GetReader();
lock (binaryReader)
{
binaryReader.BaseStream.Position = Offset;
read = binaryReader.Read(buff, startIndex, (int)size);
dataLen = binaryReader.Read(buff, startIndex, (int)size);
}
return dataLen;
}
public void WriteData(string path)

View File

@@ -29,11 +29,11 @@ namespace AssetStudio
var m_Nodes = m_Type.m_Nodes;
try
{
for (int i = 0; i < m_Nodes.Count; i++)
for (var i = 0; i < m_Nodes.Count; i++)
{
ReadStringValue(sb, m_Nodes, reader, ref i);
readed = reader.Position - reader.byteStart;
}
readed = reader.Position - reader.byteStart;
}
catch (Exception)
{
@@ -206,8 +206,8 @@ namespace AssetStudio
var m_Node = m_Nodes[i];
var varNameStr = m_Node.m_Name;
obj[varNameStr] = ReadValue(m_Nodes, reader, ref i);
readed = reader.Position - reader.byteStart;
}
readed = reader.Position - reader.byteStart;
}
catch (Exception)
{