toolkit/components/osfile/modules/ospath.jsm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/osfile/modules/ospath.jsm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/**
     1.9 + * Handling native paths.
    1.10 + *
    1.11 + * This module contains a number of functions destined to simplify
    1.12 + * working with native paths through a cross-platform API. Functions
    1.13 + * of this module will only work with the following assumptions:
    1.14 + *
    1.15 + * - paths are valid;
    1.16 + * - paths are defined with one of the grammars that this module can
    1.17 + *   parse (see later);
    1.18 + * - all path concatenations go through function |join|.
    1.19 + */
    1.20 +
    1.21 +"use strict";
    1.22 +
    1.23 +if (typeof Components == "undefined") {
    1.24 +  let Path;
    1.25 +  if (OS.Constants.Win) {
    1.26 +    Path = require("resource://gre/modules/osfile/ospath_win.jsm");
    1.27 +  } else {
    1.28 +    Path = require("resource://gre/modules/osfile/ospath_unix.jsm");
    1.29 +  }
    1.30 +  module.exports = Path;
    1.31 +} else {
    1.32 +  let Cu = Components.utils;
    1.33 +  let Scope = {};
    1.34 +  Cu.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", Scope);
    1.35 +
    1.36 +  let Path = {};
    1.37 +  if (Scope.OS.Constants.Win) {
    1.38 +    Cu.import("resource://gre/modules/osfile/ospath_win.jsm", Path);
    1.39 +  } else {
    1.40 +    Cu.import("resource://gre/modules/osfile/ospath_unix.jsm", Path);
    1.41 +  }
    1.42 +
    1.43 +  this.EXPORTED_SYMBOLS = [];
    1.44 +  for (let k in Path) {
    1.45 +    this.EXPORTED_SYMBOLS.push(k);
    1.46 +    this[k] = Path[k];
    1.47 +  }
    1.48 +}

mercurial