-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.d
92 lines (80 loc) · 2.42 KB
/
test.d
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
/+dub.sdl:
name "test"
dependency "icontheme" path="../"
+/
import std.stdio;
import std.algorithm;
import std.getopt;
import std.file;
import std.range;
import isfreedesktop;
import icontheme;
int main(string[] args)
{
string[] searchIconDirs;
bool verbose;
try {
getopt(args, "verbose", "Print name of each examined file to standard output", &verbose);
} catch(Exception e) {
stderr.writeln(e.msg);
return 1;
}
if (args.length > 1) {
searchIconDirs = args[1..$];
} else {
static if (isFreedesktop) {
searchIconDirs = baseIconDirs();
} else version(Windows) {
import std.process : environment;
import std.path : buildPath;
try {
auto root = environment.get("SYSTEMDRIVE", "C:");
auto kdeDir = root ~ `\ProgramData\KDE\share`;
if (kdeDir.isDir) {
searchIconDirs = [buildPath(kdeDir, `icons`)];
}
} catch(Exception e) {
}
}
}
if (searchIconDirs.empty) {
stderr.writeln("No icon theme directories given nor could be detected");
stderr.writefln("Usage: %s [DIRECTORY]...", args[0]);
return 1;
}
debug writefln("Using directories: %-(%s, %)", searchIconDirs);
foreach(path; iconThemePaths(searchIconDirs)) {
IconThemeFile theme;
string cachePath;
if (verbose) {
writeln("Reading icon theme file: ", path);
}
try {
theme = new IconThemeFile(path);
}
catch(IniLikeReadException e) {
stderr.writefln("Error reading %s: at %s: %s", path, e.lineNumber, e.msg);
}
catch(Exception e) {
stderr.writefln("Error reading %s: %s", path, e.msg);
}
try {
if (theme) {
cachePath = theme.cachePath;
if (cachePath.exists) {
if (verbose) {
writeln("Reading icon theme cache: ", cachePath);
}
auto cache = new IconThemeCache(cachePath);
}
}
}
catch(IconThemeCacheException e) {
stderr.writeln("Error parsing cache file %s: %s", cachePath, e.msg);
}
catch(Exception e) {
stderr.writefln("Error reading %s: %s", cachePath, e.msg);
}
}
return 0;
}