mirror of
https://silica.codes/BedrockReverse/PremiumPacksInstaller.git
synced 2025-04-24 13:46:13 +12:00
Upload v1.0
This commit is contained in:
parent
02a911de75
commit
b3a80a479a
46 changed files with 76594 additions and 0 deletions
65
PremiumPackInstaller/PlayFab/Config.cs
Normal file
65
PremiumPackInstaller/PlayFab/Config.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PlayFab
|
||||
{
|
||||
internal class Config
|
||||
{
|
||||
public static string DataFolder = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "PremiumPackInstaller");
|
||||
public static string ConfigFile = Path.Combine(DataFolder, "playfab.conf");
|
||||
|
||||
private static void initConfig()
|
||||
{
|
||||
Directory.CreateDirectory(DataFolder);
|
||||
File.WriteAllText(ConfigFile, "");
|
||||
}
|
||||
|
||||
private static void replaceConfValue(string key, string newval)
|
||||
{
|
||||
if (!File.Exists(ConfigFile))
|
||||
initConfig();
|
||||
|
||||
string[] keyValuePairs = File.ReadAllLines(ConfigFile);
|
||||
for (int i = 0; i < keyValuePairs.Length; i++)
|
||||
{
|
||||
string[] kvp = keyValuePairs[i].Split(':');
|
||||
if (kvp[0] == key)
|
||||
keyValuePairs[i] = key + ":" + newval;
|
||||
}
|
||||
|
||||
File.WriteAllLines(ConfigFile, keyValuePairs);
|
||||
}
|
||||
|
||||
public static string GetConfValue(string key)
|
||||
{
|
||||
if (!File.Exists(ConfigFile))
|
||||
initConfig();
|
||||
|
||||
string[] keyValuePairs = File.ReadAllLines(ConfigFile);
|
||||
foreach (string keyValuePair in keyValuePairs)
|
||||
{
|
||||
string[] kvp = keyValuePair.Split(':');
|
||||
if (kvp[0] == key)
|
||||
return String.Join(":", kvp.Skip(1).ToArray());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static void WriteConfValue(string key, string value)
|
||||
{
|
||||
if (!File.Exists(ConfigFile))
|
||||
initConfig();
|
||||
string curConfValue = GetConfValue(key);
|
||||
|
||||
if (curConfValue == value)
|
||||
return;
|
||||
|
||||
if (curConfValue != null)
|
||||
replaceConfValue(key, value);
|
||||
else
|
||||
File.AppendAllLines(ConfigFile, new string[] { key + ":" + value });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue