-
Notifications
You must be signed in to change notification settings - Fork 4
/
PathInfo.cs
95 lines (82 loc) · 1.8 KB
/
PathInfo.cs
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AlbLib.Texts;
using AlbLib.XLD;
namespace AlbLib
{
/// <summary>
/// Informations about path to Albion resource.
/// </summary>
public class PathInfo
{
/// <summary>
/// Absolute file path.
/// </summary>
public string FileName{
get;private set;
}
/// <summary>
/// Directory containing resource.
/// </summary>
public string Directory{
get;private set;
}
/// <summary></summary>
public PathInfo(string path)
{
FileName = Path.GetFullPath(path);
Directory = Path.GetDirectoryName(FileName);
}
/// <summary>
/// Formats variable path.
/// </summary>
public string Format(params object[] args)
{
return String.Format(this.FileName, args);
}
/// <summary>
/// Formats variable path.
/// </summary>
public string Format(int arg1)
{
return String.Format(this.FileName, arg1);
}
public virtual bool Match(string path)
{
return Path.GetFileName(path) == Path.GetFileName(FileName);
}
public PathInfo WithDefaultLanguage()
{
return Specify(TextCore.DefaultLanguageFolder);
}
protected string SpecifyFormat(params string[] args)
{
return Format((new[]{"{0}"}).Concat(args).ToArray());
}
protected virtual PathInfo SpecifyImpl(params string[] args)
{
return new PathInfo(SpecifyFormat(args));
}
public PathInfo Specify(params string[] args)
{
return SpecifyImpl(args);
}
/// <summary></summary>
public static implicit operator PathInfo(string path)
{
return new PathInfo(path);
}
/// <summary></summary>
public static implicit operator String(PathInfo info)
{
return info.ToString();
}
/// <summary></summary>
public override string ToString()
{
return FileName;
}
}
}