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