src/preferences/PreferencesBase.js
function () {
            var result = new $.Deferred();
            var path = this.path;
            var createIfMissing = this.createIfMissing;
            var recreateIfInvalid = this.recreateIfInvalid;
            var self = this;

            if (path) {
                var prefFile = FileSystem.getFileForPath(path);
                prefFile.read({}, function (err, text) {
                    if (err) {
                        if (createIfMissing) {
                            // Unreadable file is also unwritable -- delete so get recreated
                            if (recreateIfInvalid && (err === FileSystemError.NOT_READABLE || err === FileSystemError.UNSUPPORTED_ENCODING)) {
                                appshell.fs.moveToTrash(path, function (err) {
                                    if (err) {
                                        console.log("Cannot move unreadable preferences file " + path + " to trash!!");
                                    } else {
                                        console.log("Brackets has recreated the unreadable preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                                    }
                                }.bind(this));
                            }
                            result.resolve({});
                        } else {
                            result.reject(new Error("Unable to load preferences at " + path + " " + err));
                        }
                        return;
                    }

                    self._lineEndings = FileUtils.sniffLineEndings(text);

                    // If the file is empty, turn it into an empty object
                    if (/^\s*$/.test(text)) {
                        result.resolve({});
                    } else {
                        try {
                            result.resolve(JSON.parse(text));
                        } catch (e) {
                            if (recreateIfInvalid) {
                                // JSON parsing error -- recreate the preferences file
                                appshell.fs.moveToTrash(path, function (err) {
                                    if (err) {
                                        console.log("Cannot move unparseable preferences file " + path + " to trash!!");
                                    } else {
                                        console.log("Brackets has recreated the Invalid JSON preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                                    }
                                }.bind(this));
                                result.resolve({});
                            } else {
                                result.reject(new ParsingError("Invalid JSON settings at " + path + "(" + e.toString() + ")"));
                            }
                        }
                    }
                });
            } else {
                result.resolve({});
            }

            return result.promise();
        }
function () {
            var result = new $.Deferred();
            var path = this.path;
            var createIfMissing = this.createIfMissing;
            var recreateIfInvalid = this.recreateIfInvalid;
            var self = this;

            if (path) {
                var prefFile = FileSystem.getFileForPath(path);
                prefFile.read({}, function (err, text) {
                    if (err) {
                        if (createIfMissing) {
                            // Unreadable file is also unwritable -- delete so get recreated
                            if (recreateIfInvalid && (err === FileSystemError.NOT_READABLE || err === FileSystemError.UNSUPPORTED_ENCODING)) {
                                appshell.fs.moveToTrash(path, function (err) {
                                    if (err) {
                                        console.log("Cannot move unreadable preferences file " + path + " to trash!!");
                                    } else {
                                        console.log("Brackets has recreated the unreadable preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                                    }
                                }.bind(this));
                            }
                            result.resolve({});
                        } else {
                            result.reject(new Error("Unable to load preferences at " + path + " " + err));
                        }
                        return;
                    }

                    self._lineEndings = FileUtils.sniffLineEndings(text);

                    // If the file is empty, turn it into an empty object
                    if (/^\s*$/.test(text)) {
                        result.resolve({});
                    } else {
                        try {
                            result.resolve(JSON.parse(text));
                        } catch (e) {
                            if (recreateIfInvalid) {
                                // JSON parsing error -- recreate the preferences file
                                appshell.fs.moveToTrash(path, function (err) {
                                    if (err) {
                                        console.log("Cannot move unparseable preferences file " + path + " to trash!!");
                                    } else {
                                        console.log("Brackets has recreated the Invalid JSON preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                                    }
                                }.bind(this));
                                result.resolve({});
                            } else {
                                result.reject(new ParsingError("Invalid JSON settings at " + path + "(" + e.toString() + ")"));
                            }
                        }
                    }
                });
            } else {
                result.resolve({});
            }

            return result.promise();
        }
function ( ) { var result = new $ . Deferred ( ) ; var path = this . path ; var createIfMissing = this . createIfMissing ; var recreateIfInvalid = this . recreateIfInvalid ; var self = this ; if ( path ) { var prefFile = FileSystem . getFileForPath ( path ) ; prefFile . read ( { } , function ( err , text ) { if ( err ) { if ( createIfMissing ) { // Unreadable file is also unwritable -- delete so get recreated if ( recreateIfInvalid && ( err === FileSystemError . NOT_READABLE || err === FileSystemError . UNSUPPORTED_ENCODING ) ) { appshell . fs . moveToTrash ( path , function ( err ) { if ( err ) { console . log ( "Cannot move unreadable preferences file " + path + " to trash!!" ) ; } else { console . log ( "Brackets has recreated the unreadable preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!" ) ; } } . bind ( this ) ) ; } result . resolve ( { } ) ; } else { result . reject ( new Error ( "Unable to load preferences at " + path + " " + err ) ) ; } return ; } self . _lineEndings = FileUtils . sniffLineEndings ( text ) ; // If the file is empty, turn it into an empty object if ( / ^\s*$ / . test ( text ) ) { result . resolve ( { } ) ; } else { try { result . resolve ( JSON . parse ( text ) ) ; } catch ( e ) { if ( recreateIfInvalid ) { // JSON parsing error -- recreate the preferences file appshell . fs . moveToTrash ( path , function ( err ) { if ( err ) { console . log ( "Cannot move unparseable preferences file " + path + " to trash!!" ) ; } else { console . log ( "Brackets has recreated the Invalid JSON preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!" ) ; } } . bind ( this ) ) ; result . resolve ( { } ) ; } else { result . reject ( new ParsingError ( "Invalid JSON settings at " + path + "(" + e . toString ( ) + ")" ) ) ; } } } } ) ; } else { result . resolve ( { } ) ; } return result . promise ( ) ; }
Loads the preferences from disk. Can throw an exception if the file is not
readable or parseable.

@return {Promise} Resolved with the data once it has been parsed.
Loads the preferences from disk . Can throw an exception if the file is not readable or parseable .