diff options
Diffstat (limited to 'services/sync/tps/extensions/mozmill/resource/stdlib/os.js')
-rw-r--r-- | services/sync/tps/extensions/mozmill/resource/stdlib/os.js | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js index f515b9a01..fcda30572 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js @@ -1,38 +1,46 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ var EXPORTED_SYMBOLS = ['listDirectory', 'getFileForPath', 'abspath', 'getPlatform']; -function listDirectory (file) { +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cu = Components.utils; + +Cu.import("resource://gre/modules/Services.jsm"); + +function listDirectory(file) { // file is the given directory (nsIFile) var entries = file.directoryEntries; var array = []; - while (entries.hasMoreElements()) - { + + while (entries.hasMoreElements()) { var entry = entries.getNext(); - entry.QueryInterface(Components.interfaces.nsIFile); + entry.QueryInterface(Ci.nsIFile); array.push(entry); } + return array; } -function getFileForPath (path) { - var file = Components.classes["@mozilla.org/file/local;1"] - .createInstance(Components.interfaces.nsILocalFile); +function getFileForPath(path) { + var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); file.initWithPath(path); return file; } -function abspath (rel, file) { +function abspath(rel, file) { var relSplit = rel.split('/'); + if (relSplit[0] == '..' && !file.isDirectory()) { file = file.parent; } - for each(p in relSplit) { + + for each(var p in relSplit) { if (p == '..') { file = file.parent; - } else if (p == '.'){ + } else if (p == '.') { if (!file.isDirectory()) { file = file.parent; } @@ -40,14 +48,10 @@ function abspath (rel, file) { file.append(p); } } + return file.path; } -function getPlatform () { - var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Components.interfaces.nsIXULRuntime); - mPlatform = xulRuntime.OS.toLowerCase(); - return mPlatform; +function getPlatform() { + return Services.appinfo.OS.toLowerCase(); } - - |