-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.cs
67 lines (63 loc) · 2.14 KB
/
functions.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
using System;
using System.IO;
namespace Minecraft_Automatic_ModDownloader
{
public class functions
{
#region Variables
public static string configDir = Directory.GetCurrentDirectory() + @"\config.ini";
public static IniFile configfile = new IniFile("config.ini");
private static string logDir = Directory.GetCurrentDirectory() + @"\log.txt";
#endregion
#region Methods
public static bool CheckLink(string link)
{
if (link != "")
{
if (link.EndsWith("json"))
{
return true;
}
}
return false;
}
public static void CheckConfigFile()
{
if (!File.Exists(Directory.GetCurrentDirectory() + @"\config.ini"))
{
functions.configfile.Write("JsonDownloadPath", "");
functions.configfile.Write("DeleteModsOnDownload", false.ToString());
functions.configfile.Write("LogToFile", true.ToString());
}
if (!functions.configfile.KeyExists("JsonDownloadPath"))
{
functions.configfile.Write("JsonDownloadPath", "");
}
if (!functions.configfile.KeyExists("DeleteModsOnDownload"))
{
functions.configfile.Write("DeleteModsOnDownload", false.ToString());
}
if (!functions.configfile.KeyExists("LogToFile"))
{
functions.configfile.Write("LogToFile", true.ToString());
}
}
public static void LogMsg(string message)
{
CheckConfigFile();
bool logtofile = bool.TryParse(functions.configfile.Read("LogToFile"), out bool outlogbool);
if (!outlogbool)
{
logtofile = true;
}
if (logtofile)
{
DateTime msgTime = DateTime.Now;
StreamWriter sw = new StreamWriter(logDir, true);
sw.WriteLine($"[{msgTime}] {message}");
sw.Close();
}
}
#endregion
}
}