mirror of
https://github.com/alexkay/spek.git
synced 2025-04-19 18:07:37 +03:00
Don't try to save if couldn't create the config dir
Fixes a crash on OSX if the user doesn't own ~/.config
This commit is contained in:
parent
63dc489bd4
commit
9f415b383d
@ -20,10 +20,13 @@ namespace Spek {
|
||||
public class Preferences {
|
||||
private KeyFile key_file;
|
||||
private string file_name;
|
||||
private bool can_save = true;
|
||||
|
||||
private Preferences () {
|
||||
file_name = Path.build_filename (Environment.get_user_config_dir (), "spek");
|
||||
DirUtils.create_with_parents (file_name, 0755);
|
||||
if (DirUtils.create_with_parents (file_name, 0755) != 0) {
|
||||
this.can_save = false;
|
||||
}
|
||||
file_name = Path.build_filename (file_name, "preferences");
|
||||
this.key_file = new KeyFile ();
|
||||
try {
|
||||
@ -48,6 +51,9 @@ namespace Spek {
|
||||
}
|
||||
|
||||
public void save () {
|
||||
if (!can_save) {
|
||||
return;
|
||||
}
|
||||
var output = FileStream.open (file_name, "w+");
|
||||
if (output != null) {
|
||||
output.puts (key_file.to_data ());
|
||||
|
Loading…
x
Reference in New Issue
Block a user