-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPaths.cs
125 lines (102 loc) · 4.42 KB
/
Paths.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ReSharper disable InconsistentNaming
// ReSharper disable MemberCanBePrivate.Global
namespace Witlesss.Backrooms.Static;
/*
Nobody:
Working directory structure:
DB/
Alias/
Peg/
vintage.txt
Im/
bb.txt
Backup/
2024-03-14/
pack--4147302158.json [pack]
Chat/
chats.json
pack--1001699898486.json [pack] <-- /fuse by id
Fuse/
-1001541923355/
private_3D_AF.json [pack] <-- /fuse ! info
any-name-possible.json [pack] <-- /fuse info
History/
-1001541923355/
KINGPIN-funny.json [list] <-- /fuse * info
that-funny-file-1.json [list] <-- /fuse @ info
Plank/
2024-08-21 a.7819159.json [list] <-- /planks info
Board/
2024-08-21 a.270089129.json [list] <-- /boards info
log.txt
sounds.txt
Pics/
-1001539756197/
AgAD5g0AAkFXMUk+3D8D-Meme.webp
Static/
ASCII/
Emoji/
Fonts/
Fallback/
Manual/
Water/
2chan.html
4chan.html
art.jpg
texts.json
voice.ogg
config.txt
reddit-posts.json
*/
public static class Paths
{
public const string Dir_DB = "DB", Dir_Pics = "Pics", Dir_Static = "Static", Dir_Temp = "Temp";
public const string Prefix_Pack = "pack";
public const string File_Config = "config.txt";
public const string File_Log = "log.txt";
public const string File_RedditPosts = "reddit-posts.json";
public static string Dir_Alias { get; } = Path.Combine(Dir_DB, "Alias");
public static string Dir_Backup { get; } = Path.Combine(Dir_DB, "Backup");
public static string Dir_Board { get; } = Path.Combine(Dir_DB, "Board");
public static string Dir_Chat { get; } = Path.Combine(Dir_DB, "Chat");
public static string Dir_Fuse { get; } = Path.Combine(Dir_DB, "Fuse");
public static string Dir_History { get; } = Path.Combine(Dir_DB, "History");
public static string Dir_Plank { get; } = Path.Combine(Dir_DB, "Plank");
public static string File_Sounds { get; } = Path.Combine(Dir_DB, "sounds.txt");
public static string Dir_Alias_Peg { get; } = Path.Combine(Dir_Alias, "Peg");
public static string Dir_Alias_Im { get; } = Path.Combine(Dir_Alias, "Im");
public static string File_Chats { get; } = Path.Combine(Dir_Chat, "chats.json");
public static string Dir_ASCII { get; } = Path.Combine(Dir_Static, "ASCII");
public static string Dir_Emoji { get; } = Path.Combine(Dir_Static, "Emoji");
public static string Dir_Fonts { get; } = Path.Combine(Dir_Static, "Fonts");
public static string Dir_Manual { get; } = Path.Combine(Dir_Static, "Manual");
public static string Dir_Water { get; } = Path.Combine(Dir_Static, "Water");
public static string Dir_Fonts_Fallback { get; } = Path.Combine(Dir_Fonts, "Fallback");
public static string File_2chanHtmlPage { get; } = Path.Combine(Dir_Static, "2chan.html");
public static string File_4chanHtmlPage { get; } = Path.Combine(Dir_Static, "4chan.html");
public static string File_DefaultAlbumCover { get; } = Path.Combine(Dir_Static, "art.jpg");
public static string File_DefaultTexts { get; } = Path.Combine(Dir_Static, "texts.json");
public static string File_DefaultVoiceMessage { get; } = Path.Combine(Dir_Static, "voice.ogg");
public static void ClearTempFiles()
{
ClearDirectory(Dir_Temp, "*", new EnumerationOptions { RecurseSubdirectories = true });
ClearDirectory(Dir_Fuse, "del*.json", new EnumerationOptions { RecurseSubdirectories = true });
}
private static void ClearDirectory(string path, string pattern, EnumerationOptions options)
{
if (!Directory.Exists(path)) return;
var files = Directory.GetFiles(path, pattern, options);
if (files.Length == 0) return;
try
{
var onePunch = options.RecurseSubdirectories && pattern is "*";
if (onePunch) Directory.Delete(path, true);
else files.ForEach(File.Delete);
Print($"CLEAR [{path}] >> {files.Length} FILES!", ConsoleColor.Yellow);
}
catch (Exception e)
{
Print($"CAN'T CLEAR [{path}] >> {e.Message}", ConsoleColor.Red);
}
}
}