mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-06 18:15:52 +01:00
Allow exporting to a directory as well as an archive with dactyl.exportHelp.
This commit is contained in:
@@ -177,7 +177,7 @@ defineModule("base", {
|
||||
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||
"endModule", "forEach", "isArray", "isGenerator", "isinstance",
|
||||
"isObject", "isString", "isSubclass", "iter", "iterAll", "keys",
|
||||
"memoize", "properties", "set", "update", "values",
|
||||
"memoize", "octal", "properties", "set", "update", "values",
|
||||
"withCallerGlobal"
|
||||
],
|
||||
use: ["services", "util"]
|
||||
@@ -1008,6 +1008,8 @@ function UTF8(str) {
|
||||
}
|
||||
}
|
||||
|
||||
function octal(decimal) parseInt(decimal, 8);
|
||||
|
||||
/**
|
||||
* Array utility methods.
|
||||
*/
|
||||
|
||||
@@ -16,16 +16,10 @@ defineModule("storage", {
|
||||
|
||||
const win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
|
||||
function getFile(name) {
|
||||
let file = storage.infoPath.clone();
|
||||
file.append(name);
|
||||
return File(file);
|
||||
}
|
||||
|
||||
function loadData(name, store, type) {
|
||||
try {
|
||||
if (storage.infoPath)
|
||||
var file = getFile(name).read();
|
||||
var file = storage.infoPath.child(name);
|
||||
if (file)
|
||||
var result = services.json.decode(file);
|
||||
if (result instanceof type)
|
||||
@@ -38,7 +32,7 @@ function saveData(obj) {
|
||||
if (obj.privateData && storage.privateMode)
|
||||
return;
|
||||
if (obj.store && storage.infoPath)
|
||||
getFile(obj.name).write(obj.serial);
|
||||
storage.infoPath.child(obj.name).write(obj.serial);
|
||||
}
|
||||
|
||||
const StoreBase = Class("StoreBase", {
|
||||
@@ -246,12 +240,8 @@ const Storage = Module("Storage", {
|
||||
}, {
|
||||
}, {
|
||||
init: function (dactyl, modules) {
|
||||
let infoPath = File(modules.IO.runtimePath.replace(/,.*/, ""));
|
||||
if (infoPath) {
|
||||
infoPath.append("info");
|
||||
infoPath.append(dactyl.profileName);
|
||||
storage.infoPath = infoPath;
|
||||
}
|
||||
storage.infoPath = File(modules.IO.runtimePath.replace(/,.*/, ""))
|
||||
.child("info").child(dactyl.profileName);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -268,7 +258,7 @@ const File = Class("File", {
|
||||
let file = services.File();
|
||||
|
||||
if (path instanceof Ci.nsIFile)
|
||||
file = path.QueryInterface(Ci.nsIFile);
|
||||
file = path.QueryInterface(Ci.nsIFile).clone();
|
||||
else if (/file:\/\//.test(path))
|
||||
file = services["File:"]().getFileFromURLSpec(path);
|
||||
else {
|
||||
@@ -300,6 +290,15 @@ const File = Class("File", {
|
||||
yield File(file);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new file for the given child of this directory entry.
|
||||
*/
|
||||
child: function (name) {
|
||||
let f = this.constructor(this);
|
||||
f.append(name);
|
||||
return f;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reads this file's entire contents in "text" mode and returns the
|
||||
* content as a string.
|
||||
@@ -398,7 +397,7 @@ const File = Class("File", {
|
||||
mode = File.MODE_WRONLY | File.MODE_CREATE | File.MODE_TRUNCATE;
|
||||
|
||||
if (!perms)
|
||||
perms = parseInt('0644', 8);
|
||||
perms = octal(644);
|
||||
if (!this.exists()) // OCREAT won't create the directory
|
||||
this.create(this.NORMAL_FILE_TYPE, perms);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user