From 883cbb295491699abdaea971f3ec02f4882f4a81 Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 28 Oct 2017 11:46:03 +0400 Subject: [PATCH] (FormatCatalog): added ReadFileList method. --- GameRes/FormatCatalog.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/GameRes/FormatCatalog.cs b/GameRes/FormatCatalog.cs index b41bc017..9135d527 100644 --- a/GameRes/FormatCatalog.cs +++ b/GameRes/FormatCatalog.cs @@ -313,6 +313,27 @@ namespace GameRes return reader.ReadInt32(); } } + + /// + /// Read text file from data directory, performing action on each line. + /// + public void ReadFileList (string filename, Action process_line) + { + var lst_file = Path.Combine (DataDirectory, filename); + if (!File.Exists (lst_file)) + return; + using (var input = new StreamReader (lst_file)) + { + string line; + while ((line = input.ReadLine()) != null) + { + if (line.Length > 0) + { + process_line (line); + } + } + } + } } ///