Linux: store config in ~/.config/Vocaluxe instead of in install dir

because we might not have permission to write there if installed as a package
If that folder doesn't exist, create it and copy the default profiles there,
so they show up but can still be edited or removed
This commit is contained in:
derivator committed 2015-03-01 02:14:01 +01:00
1 parent 1b86baa24d
commit acd89bc2d3
3 files changed
+24 -1

No files matched your search

+20
View File
@@ -96,6 +96,23 @@ namespace Vocaluxe
return _IsProgramInstalled("Microsoft Visual C++ 2010");
}
private static void _EnsureDataFolderExists()
{
if (!Directory.Exists(CSettings.DataFolder)) {
Directory.CreateDirectory(CSettings.DataFolder);
// copy default profiles to DataFolder instead of adding ProgramFolder to CConfig.ProfileFolders
// because we want to be able to edit them, but might not have permission to write to ProgramFolder
string profilePath = Path.Combine(CSettings.DataFolder, CSettings.FolderNameProfiles);
Directory.CreateDirectory(profilePath);
DirectoryInfo defaultProfileDir = new DirectoryInfo(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameProfiles));
FileInfo[] files = defaultProfileDir.GetFiles();
foreach (FileInfo file in files) {
string newPath = Path.Combine(profilePath, file.Name);
file.CopyTo(newPath, false);
}
}
}
public static bool CheckRequirements()
{
#if WIN
@@ -135,6 +152,9 @@ namespace Vocaluxe
#endif
path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + path;
COSFunctions.AddEnvironmentPath(path);
#if LINUX
_EnsureDataFolderExists();
#endif
}
}
}