mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(TryOpen): check formats that match filename extension first.
This commit is contained in:
parent
b3e35162f6
commit
64f38255ee
@ -58,18 +58,22 @@ namespace GameRes
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to open <paramref name="filename"/> as archive.
|
/// Try to open <paramref name="filename"/> as archive.
|
||||||
/// Returns: ArcFile object if file is opened successfully, null otherwise.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// ArcFile object if file is opened successfully, null otherwise.
|
||||||
|
/// </returns>
|
||||||
public static ArcFile TryOpen (string filename)
|
public static ArcFile TryOpen (string filename)
|
||||||
{
|
{
|
||||||
var file = new ArcView (filename);
|
var file = new ArcView (filename);
|
||||||
|
string ext = Path.GetExtension (filename).TrimStart ('.').ToLower();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint signature = file.View.ReadUInt32 (0);
|
uint signature = file.View.ReadUInt32 (0);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
var range = FormatCatalog.Instance.LookupSignature<ArchiveFormat> (signature);
|
var range = FormatCatalog.Instance.LookupSignature<ArchiveFormat> (signature);
|
||||||
foreach (var impl in range)
|
// check formats that match filename extension first
|
||||||
|
foreach (var impl in range.OrderByDescending (f => f.Extensions.First() == ext))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user