use FormatCatalog.ReadFileList method to read file lists.

This commit is contained in:
morkt 2017-10-28 11:49:15 +04:00
parent 4517bd55e8
commit ac27791ea3
3 changed files with 9 additions and 42 deletions

View File

@ -168,21 +168,9 @@ namespace GameRes.Formats.Neko
{ {
try try
{ {
var dir = FormatCatalog.Instance.DataDirectory; var names = new List<string>();
var lst_file = Path.Combine (dir, "nekopack.lst"); FormatCatalog.Instance.ReadFileList ("nekopack.lst", name => names.Add (name));
if (!File.Exists (lst_file)) return names.ToArray();
return new string[0];
using (var input = new StreamReader (lst_file))
{
var names = new List<string>();
string line;
while ((line = input.ReadLine()) != null)
{
if (line.Length > 0)
names.Add (line);
}
return names.ToArray();
}
} }
catch (Exception X) catch (Exception X)
{ {

View File

@ -1208,21 +1208,12 @@ namespace GameRes.Formats.KiriKiri
void ReadNames () void ReadNames ()
{ {
var dir = FormatCatalog.Instance.DataDirectory;
var names_file = Path.Combine (dir, FileListName);
var names = new Dictionary<uint, string>(); var names = new Dictionary<uint, string>();
try try
{ {
using (var reader = new StreamReader (names_file)) FormatCatalog.Instance.ReadFileList (FileListName, name => {
{ names[GetNameHash (name)] = name;
for (;;) });
{
var name = reader.ReadLine();
if (null == name)
break;
names[GetNameHash (name)] = name;
}
}
} }
catch (Exception X) catch (Exception X)
{ {

View File

@ -210,21 +210,9 @@ namespace GameRes.Formats.Tanuki
{ {
try try
{ {
var dir = FormatCatalog.Instance.DataDirectory; var names = new List<string>();
var lst_file = Path.Combine (dir, ListFileName); FormatCatalog.Instance.ReadFileList (ListFileName, name => names.Add (name));
if (!File.Exists (lst_file)) return names.ToArray();
return new string[0];
using (var input = new StreamReader (lst_file))
{
var names = new List<string>();
string line;
while ((line = input.ReadLine()) != null)
{
if (line.Length > 0)
names.Add (line);
}
return names.ToArray();
}
} }
catch (Exception X) catch (Exception X)
{ {