requested changes

This commit is contained in:
Caraxi 2023-07-21 22:59:04 +09:30
parent 9023aa8006
commit 57a4e65383
2 changed files with 29 additions and 27 deletions

View file

@ -178,31 +178,30 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
}
public long OriginalSize { get; private set; } = OriginalSize;
public long CompressedSize { get; private set; } = CompressedSize;
private string? _format;
public string? Format
public Lazy<string> Format = new(() =>
{
get
switch (FileType)
{
if (_format != null) return _format;
switch (FileType)
{
case "tex":
case "tex":
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat) reader.ReadInt32();
_format = format.ToString();
return _format;
try
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat)reader.ReadInt32();
return format.ToString();
}
catch
{
return "unknown";
}
}
default:
_format = string.Empty;
return _format;
}
default:
return string.Empty;
}
}
});
}
}