/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/settings_data.js

  • Committer: Gustav Hartvigsson
  • Date: 2015-06-05 19:06:14 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150605190614-s410mh65n2jdxtcv
* Cleaded up a lille code
* Fixed a nasty segfault that could occur if the conig folder did not exist.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    this.parent (params);
82
82
    
83
83
    /* First we construct the path for where to store the settings file. */
84
 
    this._settings_file_path = "";
85
 
    this._settings_file_path += GLib.get_user_config_dir ();
86
 
    this._settings_file_path += "/gpump/gpump.json";
 
84
    this._settings_file_path = "" + 
 
85
                              GLib.get_user_config_dir () +
 
86
                              "/gpump/gpump.json";
87
87
    print ("Config file is: " + this._settings_file_path);
88
88
    
89
89
    this._settings_file = Gio.File.new_for_path (this._settings_file_path);
113
113
      // DEBUG:
114
114
      print (JSON.stringify (this._settings, null, 2).toString () );
115
115
      
 
116
      // Check if the folder exists, and if it does not exist, create it.
 
117
      let folder_path = "" + GLib.get_user_config_dir () +
 
118
                                          "/gpump/"
 
119
      let folder = Gio.File.new_for_path (folder_path);
 
120
      if (!GLib.file_test (folder_path, GLib.FileTest.EXISTS)) {
 
121
        folder.make_directory (null);
 
122
      }
 
123
      
116
124
      let file_stream = this._settings_file.create (Gio.FileCreateFlags.PRIVATE,
117
125
                                                    null);
 
126
      
118
127
      file_stream.write_all (JSON.stringify (
119
128
          this._settings, null, 2).toString (), null);
120
129