mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-29 20:03:33 +02:00
Add IO#File.
New review: owner: dougkearns I like this for the most part, except that it has to go to lengths to wrap the original nsIFile correctly, an that it can't be passed directly to other XPCOM components. It makes most operations on files a lot cleaner, though.
This commit is contained in:
@@ -563,21 +563,20 @@ function Events() //{{{
|
||||
for (let [, dir] in Iterator(dirs))
|
||||
{
|
||||
liberator.echomsg('Searching for "macros/*" in "' + dir.path + '"', 2);
|
||||
|
||||
liberator.log("Sourcing macros directory: " + dir.path + "...", 3);
|
||||
|
||||
let files = io.readDirectory(dir.path);
|
||||
for (let file in dir.iterDirectory())
|
||||
{
|
||||
if (file.exists() && !file.isDirectory() && file.isReadable() &&
|
||||
/^[\w_-]+(\.vimp)?$/i.test(file.leafName))
|
||||
{
|
||||
let name = file.leafName.replace(/\.vimp$/i, "");
|
||||
macros.set(name, file.read().split("\n")[0]);
|
||||
|
||||
files.forEach(function (file) {
|
||||
if (!file.exists() || file.isDirectory() ||
|
||||
!file.isReadable() || !/^[\w_-]+(\.vimp)?$/i.test(file.leafName))
|
||||
return;
|
||||
|
||||
let name = file.leafName.replace(/\.vimp$/i, "");
|
||||
macros.set(name, io.readFile(file).split("\n")[0]);
|
||||
|
||||
liberator.log("Macro " + name + " added: " + macros.get(name), 5);
|
||||
});
|
||||
liberator.log("Macro " + name + " added: " + macros.get(name), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user