How to use the url.toFilename function in url

To help you get started, we’ve selected a few url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozillaarchive / deuxdrop / clients / addon / lib / nacl.js View on Github external
case 'Linux':
    platLibName = 'libnacl-' + platCode + '.so';
    break;
  case 'Darwin':
    if (numbits !== 64)
      throw new Error('32-bit OS X not supported right now.');
    platLibName = 'libnacl-x86_64.dylib';
    break;
  case 'Android':
    platLibName = 'libnacl-arm.so';
    break;
  default:
    throw new Error('No native library for platform: ' + runtime.OS);
}
// NOTE: the libs now get packaged in the data sub-tree!
let path = $url.toFilename(
             $self.data.url("nacl-native-libs/" + platLibName).toString());

let NACL = $ctypes.open(path);

$unload.when(function() {
  NACL.close();
});

////////////////////////////////////////////////////////////////////////////////
// Strings, Types

const pustr = $ctypes.unsigned_char.ptr,
      Sizey = $ctypes.unsigned_long_long;

function ustr_t(x) {
  return $ctypes.unsigned_char.array(x);
github mozilla / addon-builder-helper / tests / test-xpi-installation.js View on Github external
function getDataFile(filename) {
  var myFilename = require("url").toFilename(__url__);
  var file = Cc['@mozilla.org/file/local;1']
             .createInstance(Ci.nsILocalFile);
  file.initWithPath(myFilename);
  file = file.parent.parent;
  file.append('examples');
  file.append('sample-web-page');
  file.append(filename);
  return file;
}
github mozilla / chromeless / tests / test-url.js View on Github external
    function() { url.toFilename("resource://nonexistent"); },
    "resource does not exist: resource://nonexistent/",
github mozilla / openwebapps / addons / jetpack / lib / nativeshell.js View on Github external
function embedMozAppsAPIFiles(destDir)
{
  //this is slightly sketchy, going up out of the data dir and into the lib dir to fetch a file...
  let dataURL = self.data.url(".");
  let dataPath = url.toFilename(dataURL);
  let injectorSrc = Cc['@mozilla.org/file/local;1']
                    .createInstance(Ci.nsILocalFile);
  injectorSrc.initWithPath(dataPath);
  injectorSrc = injectorSrc.parent;
  injectorSrc.append("lib");
  injectorSrc.append("injector.js");

  var injectorDest = destDir.clone();
  injectorDest.append("injector.js");

  copyFile(injectorSrc.path, injectorDest.path);
}
github mozilla / chromeless / modules / lib / self-e10s-adapter.js View on Github external
addon.registerCall("self:load", function(name, path, stack) {
      let data_url = getURL(path, stack, 1);
      let fn = url.toFilename(data_url);
      let data = file.read(fn);
      return data;
    });
    addon.registerCall("self:url", function(name, path, stack) {
github mozilla / chromeless / modules / lib / self.js View on Github external
load: function load(name) {
        let data_url = getURL(name, 1);
        let fn = url.toFilename(data_url);
        let data = file.read(fn);
        return data;
    },
    url: function url(name) { return getURL(name, 1); }
github mozilla / chromeless / packages / nsjetpack / lib / nsjetpack.js View on Github external
exports.get = function get() {
  if (!component) {
    var path = url.toFilename(url.URL("platform", __url__).toString());
    xpcom.autoRegister(path);

    var factory = xpcom.getClass("@labs.mozilla.com/jetpackdi;1",
                                 Ci.nsIFactory);
    var nsJetpack = factory.createInstance(null, Ci.nsISupports);
    component = nsJetpack.get();
  }
  return component;
};