toolkit/components/osfile/modules/ospath.jsm

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 /**
michael@0 6 * Handling native paths.
michael@0 7 *
michael@0 8 * This module contains a number of functions destined to simplify
michael@0 9 * working with native paths through a cross-platform API. Functions
michael@0 10 * of this module will only work with the following assumptions:
michael@0 11 *
michael@0 12 * - paths are valid;
michael@0 13 * - paths are defined with one of the grammars that this module can
michael@0 14 * parse (see later);
michael@0 15 * - all path concatenations go through function |join|.
michael@0 16 */
michael@0 17
michael@0 18 "use strict";
michael@0 19
michael@0 20 if (typeof Components == "undefined") {
michael@0 21 let Path;
michael@0 22 if (OS.Constants.Win) {
michael@0 23 Path = require("resource://gre/modules/osfile/ospath_win.jsm");
michael@0 24 } else {
michael@0 25 Path = require("resource://gre/modules/osfile/ospath_unix.jsm");
michael@0 26 }
michael@0 27 module.exports = Path;
michael@0 28 } else {
michael@0 29 let Cu = Components.utils;
michael@0 30 let Scope = {};
michael@0 31 Cu.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", Scope);
michael@0 32
michael@0 33 let Path = {};
michael@0 34 if (Scope.OS.Constants.Win) {
michael@0 35 Cu.import("resource://gre/modules/osfile/ospath_win.jsm", Path);
michael@0 36 } else {
michael@0 37 Cu.import("resource://gre/modules/osfile/ospath_unix.jsm", Path);
michael@0 38 }
michael@0 39
michael@0 40 this.EXPORTED_SYMBOLS = [];
michael@0 41 for (let k in Path) {
michael@0 42 this.EXPORTED_SYMBOLS.push(k);
michael@0 43 this[k] = Path[k];
michael@0 44 }
michael@0 45 }

mercurial