mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-23 20:34:07 +02:00
Add support for a -datafolder command line argument
This commit is contained in:
parent
f39fd00697
commit
ba6ce072ac
22
Program.cs
22
Program.cs
@ -36,8 +36,8 @@ static class Program{
|
|||||||
public static readonly bool IsPortable = File.Exists("makeportable");
|
public static readonly bool IsPortable = File.Exists("makeportable");
|
||||||
|
|
||||||
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), BrandName);
|
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : GetDataStoragePath();
|
||||||
public static readonly string TemporaryPath = IsPortable ? Path.Combine(ProgramPath, "portable", "tmp") : Path.Combine(Path.GetTempPath(), BrandName);
|
public static readonly string TemporaryPath = IsPortable ? Path.Combine(ProgramPath, "portable", "tmp") : Path.Combine(Path.GetTempPath(), BrandName+'_'+Path.GetRandomFileName().Substring(0, 6));
|
||||||
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
||||||
|
|
||||||
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
|
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
|
||||||
@ -167,6 +167,24 @@ private static void plugins_Reloaded(object sender, PluginLoadEventArgs e){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetCmdArgumentValue(string search){
|
||||||
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
|
int index = Array.FindIndex(args, arg => arg.Equals(search, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
return index >= 0 && index < args.Length-1 ? args[index+1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDataStoragePath(){
|
||||||
|
string custom = GetCmdArgumentValue("-datafolder");
|
||||||
|
|
||||||
|
if (custom != null && (custom.Contains(Path.DirectorySeparatorChar) || custom.Contains(Path.AltDirectorySeparatorChar))){
|
||||||
|
return custom;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), custom ?? BrandName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void HandleException(string message, Exception e){
|
public static void HandleException(string message, Exception e){
|
||||||
Log(e.ToString());
|
Log(e.ToString());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user