From a988b48016a24d18435f5a7ba46caeb5e6c53608 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 18 Jan 2015 18:01:58 -0800 Subject: [PATCH] Implement app.getHomeDir with app.getPath --- atom/browser/api/atom_api_app.cc | 2 ++ atom/browser/api/lib/app.coffee | 12 +++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index d5c688352980..884c3d90a0ce 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -67,6 +67,8 @@ int GetPathConstant(const std::string& name) { return brightray::DIR_APP_DATA; else if (name == "userData") return brightray::DIR_USER_DATA; + else if (name == "home") + return base::DIR_HOME; else return -1; } diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 5ac0d719f4c9..aad56fd91238 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -5,15 +5,6 @@ bindings = process.atomBinding 'app' app = bindings.app app.__proto__ = EventEmitter.prototype -app.getHomeDir = -> - process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME'] - -app.getDataPath = -> - app.getPath 'userData' - -app.setDataPath = (path) -> - app.setPath 'userData', path - app.setApplicationMenu = (menu) -> require('menu').setApplicationMenu menu @@ -38,6 +29,9 @@ if process.platform is 'darwin' app.once 'ready', -> app.emit 'finish-launching' app.terminate = app.quit app.exit = process.exit +app.getHomeDir = -> app.getPath 'home' +app.getDataPath = -> app.getPath 'userData' +app.setDataPath = (path) -> app.setPath 'userData', path # Only one App object pemitted. module.exports = app