-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCReaderList.cs
More file actions
62 lines (57 loc) · 1.19 KB
/
CReaderList.cs
File metadata and controls
62 lines (57 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.IO;
using RapIni;
namespace RapChessGui
{
public class CReader
{
public string dir = String.Empty;
public string bookReader = Global.none;
}
public class CReaderList : List<CReader>
{
public static CRapIni iniFile = new CRapIni(@"Ini\readers.ini");
public void LoadFromIni()
{
Clear();
bool reset = true;
string[] dirs = Directory.GetDirectories("Books");
foreach (string dir in dirs)
{
CReader db = new CReader();
db.dir = Path.GetFileName(dir);
db.bookReader = iniFile.Read(db.dir);
Add(db);
if (db.bookReader != String.Empty)
reset = false;
}
if (reset)
{
reset = false;
foreach (CReader r in this)
foreach (string fr in CData.fileBookReader)
{
string ld = r.dir.ToLower();
string lf = fr.ToLower();
int li = lf.LastIndexOf(ld);
if (li == lf.Length - ld.Length - 4)
{
reset = true;
r.bookReader = fr;
break;
}
}
if (reset)
SaveToIni();
}
}
public void SaveToIni()
{
iniFile.Clear();
foreach (CReader db in this)
iniFile.Write(db.dir, db.bookReader);
iniFile.Save();
}
}
}