mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(VFS.IsPathEqualsToFileName): new method.
This commit is contained in:
parent
06718d88e9
commit
1d7369a2e4
@ -331,7 +331,7 @@ namespace GameRes.Formats.AZSys
|
||||
if (null != scheme.ContentKey)
|
||||
return scheme.ContentKey.Value;
|
||||
|
||||
if ("system.arc".Equals (Path.GetFileName (file.Name), StringComparison.InvariantCultureIgnoreCase))
|
||||
if (VFS.IsPathEqualsToFileName (file.Name, "system.arc"))
|
||||
{
|
||||
return ReadSysenvSeed (file, dir, scheme.IndexKey);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace GameRes.Formats.KAAS
|
||||
return null;
|
||||
var dir = new List<Entry> (count);
|
||||
int index_offset = 0x10;
|
||||
bool is_voice = Path.GetFileName (file.Name).Equals ("voice.pb", StringComparison.InvariantCultureIgnoreCase);
|
||||
bool is_voice = VFS.IsPathEqualsToFileName (file.Name, "voice.pb");
|
||||
int data_offset = index_offset + 8 * count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ namespace GameRes.Formats.MAI
|
||||
dir_offset += 8;
|
||||
}
|
||||
}
|
||||
bool is_mask_arc = "mask.arc" == Path.GetFileName (file.Name).ToLowerInvariant();
|
||||
bool is_mask_arc = VFS.IsPathEqualsToFileName (file.Name, "mask.arc");
|
||||
var dir = new List<Entry> (count);
|
||||
int next_folder = null == folders ? count : folders[0].Index;
|
||||
int folder = 0;
|
||||
|
@ -101,7 +101,7 @@ namespace GameRes.Formats.Rpm
|
||||
|
||||
// special case for "instdata.arc" archives
|
||||
if (scheme.Keyword != "inst"
|
||||
&& Path.GetFileName (file.Name).Equals ("instdata.arc", StringComparison.InvariantCultureIgnoreCase))
|
||||
&& VFS.IsPathEqualsToFileName (file.Name, "instdata.arc"))
|
||||
scheme = new EncryptionScheme ("inst", scheme.NameLength);
|
||||
|
||||
int index_size = count * (scheme.NameLength + 12);
|
||||
|
@ -54,7 +54,7 @@ namespace GameRes.Formats.Silky
|
||||
return null;
|
||||
|
||||
// rather loose criterion, haven't found anything better yet.
|
||||
bool is_mp3 = Path.GetFileName (file.Name).Equals ("voice.awf", StringComparison.InvariantCultureIgnoreCase);
|
||||
bool is_mp3 = VFS.IsPathEqualsToFileName (file.Name, "voice.awf");
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
@ -136,9 +136,8 @@ namespace GameRes.Formats.Rugp
|
||||
if (null == arc_man)
|
||||
return null;
|
||||
}
|
||||
var base_name = Path.GetFileName (file.Name);
|
||||
var arc_object = arc_man.ArcList.FirstOrDefault();
|
||||
if (null == arc_object || !base_name.Equals (arc_object.RioName, StringComparison.InvariantCultureIgnoreCase))
|
||||
if (null == arc_object || !VFS.IsPathEqualsToFileName (file.Name, arc_object.RioName))
|
||||
return null;
|
||||
return new RioReader (arc_man, file);
|
||||
}
|
||||
|
@ -783,6 +783,26 @@ namespace GameRes
|
||||
{
|
||||
return m_vfs.Top.GetFiles (pattern);
|
||||
}
|
||||
|
||||
static readonly char[] PathSeparatorChars = { '\\', '/', ':' };
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if given <paramref name="path"/> points to a specified <paramref name="filename"/>.
|
||||
/// </summary>
|
||||
public static bool IsPathEqualsToFileName (string path, string filename)
|
||||
{
|
||||
// first, filter out completely different paths
|
||||
if (!path.EndsWith (filename, StringComparison.InvariantCultureIgnoreCase))
|
||||
return false;
|
||||
// now, compare length of filename portion of the path
|
||||
int filename_index = path.LastIndexOfAny (PathSeparatorChars);
|
||||
if (-1 == filename_index)
|
||||
filename_index = 0;
|
||||
else
|
||||
filename_index++;
|
||||
int filename_portion_length = path.Length - filename_index;
|
||||
return filename.Length == filename_portion_length;
|
||||
}
|
||||
}
|
||||
|
||||
public class FileNameGlob
|
||||
|
Loading…
x
Reference in New Issue
Block a user