fixing HomePath on linux
This commit is contained in:
parent
4e4814e17a
commit
582a6b5c1f
|
@ -42,19 +42,21 @@ namespace SparkleLib {
|
||||||
get {
|
get {
|
||||||
if (GetConfigOption ("home_path") != null) {
|
if (GetConfigOption ("home_path") != null) {
|
||||||
return GetConfigOption ("home_path");
|
return GetConfigOption ("home_path");
|
||||||
|
|
||||||
} else {
|
} else if (SparkleHelpers.IsWindows) {
|
||||||
try {
|
try {
|
||||||
Environment.SpecialFolder folder =
|
Environment.SpecialFolder folder =
|
||||||
(Environment.SpecialFolder) Enum.Parse (
|
(Environment.SpecialFolder) Enum.Parse (
|
||||||
typeof(Environment.SpecialFolder), "UserProfile");
|
typeof(Environment.SpecialFolder), "UserProfile");
|
||||||
|
|
||||||
return (Environment.GetFolderPath (folder));
|
return (Environment.GetFolderPath (folder));
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +80,14 @@ namespace SparkleLib {
|
||||||
Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SparkleShare");
|
Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SparkleShare");
|
||||||
|
|
||||||
if (Directory.Exists (old_path) &&
|
if (Directory.Exists (old_path) &&
|
||||||
Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||||
|
|
||||||
string new_path = Path.Combine (Environment.GetFolderPath (folder), "SparkleShare");
|
string new_path = Path.Combine (Environment.GetFolderPath (folder), "SparkleShare");
|
||||||
Directory.Move (old_path, new_path);
|
Directory.Move (old_path, new_path);
|
||||||
|
|
||||||
Console.WriteLine ("Migrated SparkleShare folder to %USERPROFILE%");
|
Console.WriteLine ("Migrated SparkleShare folder to %USERPROFILE%");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine ("Failed to migrate: " + e.Message);
|
Console.WriteLine ("Failed to migrate: " + e.Message);
|
||||||
|
@ -113,7 +115,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Load (FullPath);
|
Load (FullPath);
|
||||||
|
|
||||||
} catch (TypeInitializationException) {
|
} catch (TypeInitializationException) {
|
||||||
CreateInitialConfig ();
|
CreateInitialConfig ();
|
||||||
|
|
||||||
|
@ -121,9 +123,9 @@ namespace SparkleLib {
|
||||||
CreateInitialConfig ();
|
CreateInitialConfig ();
|
||||||
|
|
||||||
} catch (XmlException) {
|
} catch (XmlException) {
|
||||||
|
|
||||||
FileInfo file = new FileInfo (FullPath);
|
FileInfo file = new FileInfo (FullPath);
|
||||||
|
|
||||||
if (file.Length == 0) {
|
if (file.Length == 0) {
|
||||||
File.Delete (FullPath);
|
File.Delete (FullPath);
|
||||||
CreateInitialConfig ();
|
CreateInitialConfig ();
|
||||||
|
@ -185,7 +187,7 @@ namespace SparkleLib {
|
||||||
);
|
);
|
||||||
|
|
||||||
SparkleUser user = new SparkleUser (name, email);
|
SparkleUser user = new SparkleUser (name, email);
|
||||||
|
|
||||||
if (File.Exists (pubkey_file_path))
|
if (File.Exists (pubkey_file_path))
|
||||||
user.PublicKey = File.ReadAllText (pubkey_file_path);
|
user.PublicKey = File.ReadAllText (pubkey_file_path);
|
||||||
|
|
||||||
|
@ -410,7 +412,7 @@ namespace SparkleLib {
|
||||||
private string GetFolderValue (string name, string key)
|
private string GetFolderValue (string name, string key)
|
||||||
{
|
{
|
||||||
XmlNode folder = GetFolder(name);
|
XmlNode folder = GetFolder(name);
|
||||||
|
|
||||||
if ((folder != null) && (folder [key] != null)) {
|
if ((folder != null) && (folder [key] != null)) {
|
||||||
return folder [key].InnerText;
|
return folder [key].InnerText;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue