mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-07 13:34:11 +01:00
Cleanup io.js with relation to path separators
This commit is contained in:
@@ -1393,7 +1393,7 @@ function Completion() //{{{
|
|||||||
// TODO: use path for the description?
|
// TODO: use path for the description?
|
||||||
io.getRuntimeDirectories("colors").forEach(function (dir) {
|
io.getRuntimeDirectories("colors").forEach(function (dir) {
|
||||||
context.fork(dir.path, 0, null, function (context) {
|
context.fork(dir.path, 0, null, function (context) {
|
||||||
context.filter = dir.path + io.pathSeparator + context.filter;
|
context.filter = dir.path + IO.PATH_SEP + context.filter;
|
||||||
completion.file(context);
|
completion.file(context);
|
||||||
context.title = ["Color Scheme"];
|
context.title = ["Color Scheme"];
|
||||||
context.quote = ["", function (text) text.replace(/\.vimp$/, ""), ""];
|
context.quote = ["", function (text) text.replace(/\.vimp$/, ""), ""];
|
||||||
|
|||||||
@@ -104,12 +104,7 @@ function IO() //{{{
|
|||||||
.map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir);
|
.map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replacePathSep(path)
|
function replacePathSep(path) path.replace("/", IO.PATH_SEP, "g");
|
||||||
{
|
|
||||||
if (WINDOWS)
|
|
||||||
return path.replace("/", "\\");
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
function joinPaths(head, tail)
|
function joinPaths(head, tail)
|
||||||
{
|
{
|
||||||
@@ -272,7 +267,7 @@ function IO() //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
// TODO: "E172: Only one file name allowed"
|
// TODO: "E172: Only one file name allowed"
|
||||||
let filename = args[0] || "~/" + (WINDOWS ? "_" : ".") + EXTENSION_NAME + "rc";
|
let filename = args[0] || io.getRCFile(null, true).path;
|
||||||
let file = io.getFile(filename);
|
let file = io.getFile(filename);
|
||||||
|
|
||||||
if (file.exists() && !args.bang)
|
if (file.exists() && !args.bang)
|
||||||
@@ -404,8 +399,6 @@ function IO() //{{{
|
|||||||
|
|
||||||
sourcing: null,
|
sourcing: null,
|
||||||
|
|
||||||
pathSeparator: WINDOWS ? "\\" : "/",
|
|
||||||
|
|
||||||
expandPath: IO.expandPath,
|
expandPath: IO.expandPath,
|
||||||
|
|
||||||
// TODO: there seems to be no way, short of a new component, to change
|
// TODO: there seems to be no way, short of a new component, to change
|
||||||
@@ -456,7 +449,7 @@ function IO() //{{{
|
|||||||
return dirs;
|
return dirs;
|
||||||
},
|
},
|
||||||
|
|
||||||
getRCFile: function (dir)
|
getRCFile: function (dir, always)
|
||||||
{
|
{
|
||||||
dir = dir || "~";
|
dir = dir || "~";
|
||||||
|
|
||||||
@@ -470,8 +463,9 @@ function IO() //{{{
|
|||||||
return rcFile1;
|
return rcFile1;
|
||||||
else if (rcFile2.exists() && rcFile2.isFile())
|
else if (rcFile2.exists() && rcFile2.isFile())
|
||||||
return rcFile2;
|
return rcFile2;
|
||||||
else
|
else if (always)
|
||||||
return null;
|
return rcFile1;
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
// return a nsILocalFile for path where you can call isDirectory(), etc. on
|
// return a nsILocalFile for path where you can call isDirectory(), etc. on
|
||||||
@@ -921,15 +915,19 @@ lookup:
|
|||||||
|
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
IO.__defineGetter__("runtimePath", function () service["environment"].get(config.name.toUpperCase() + "_RUNTIME") ||
|
IO.PATH_SEP = (function () {
|
||||||
|
let file = services.create("file");
|
||||||
|
file.append("foo");
|
||||||
|
return file.path[0];
|
||||||
|
})();
|
||||||
|
|
||||||
|
IO.__defineGetter__("runtimePath", function () services.get("environment").get(config.name.toUpperCase() + "_RUNTIME") ||
|
||||||
"~/" + (liberator.has("Win32") ? "" : ".") + config.name.toLowerCase());
|
"~/" + (liberator.has("Win32") ? "" : ".") + config.name.toLowerCase());
|
||||||
|
|
||||||
IO.expandPath = function (path, relative)
|
IO.expandPath = function (path, relative)
|
||||||
{
|
{
|
||||||
// TODO: proper pathname separator translation like Vim - this should be done elsewhere
|
// TODO: proper pathname separator translation like Vim - this should be done elsewhere
|
||||||
const WINDOWS = liberator.has("Win32");
|
const WINDOWS = liberator.has("Win32");
|
||||||
if (WINDOWS)
|
|
||||||
path = path.replace("/", "\\", "g");
|
|
||||||
|
|
||||||
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
||||||
// TODO: Vim does not expand variables set to an empty string (and documents it).
|
// TODO: Vim does not expand variables set to an empty string (and documents it).
|
||||||
@@ -959,10 +957,7 @@ IO.expandPath = function (path, relative)
|
|||||||
// TODO: Vim expands paths twice, once before checking for ~, once
|
// TODO: Vim expands paths twice, once before checking for ~, once
|
||||||
// after, but doesn't document it. Is this just a bug? --Kris
|
// after, but doesn't document it. Is this just a bug? --Kris
|
||||||
path = expand(path);
|
path = expand(path);
|
||||||
|
return path.replace("/", IO.PATH_SEP, "g");
|
||||||
// FIXME: Should we be doing this here? I think it should be done
|
|
||||||
// by the arg parser or nowhere. --Kris
|
|
||||||
return path.replace("\\ ", " ", "g");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user