fix windows path handling issues

pull/327/head
nightwing 2016-06-28 23:00:44 +04:00
rodzic 91f98d3aee
commit 30129604cc
5 zmienionych plików z 14 dodań i 14 usunięć

Wyświetl plik

@ -109,7 +109,7 @@
"c9.ide.recentfiles": "#7c099abf40",
"c9.ide.remote": "#301d2ab519",
"c9.ide.processlist": "#2b12cd1bdd",
"c9.ide.run": "#d661a7b847",
"c9.ide.run": "#20a43e01e4",
"c9.ide.run.build": "#0598fff697",
"c9.ide.run.debug.xdebug": "#054367574c",
"c9.ide.save": "#25a63f31e2",

Wyświetl plik

@ -122,9 +122,9 @@ define(function(require, module, exports) {
emit("quit");
}
function toExternalPath(path) {
function toExternalPath(path, sep) {
if (plugin.platform == "win32")
path = path.replace(/^[/]+/, "").replace(/[/]+/g, "\\");
path = path.replace(/^[/]+/, "").replace(/[/]+/g, sep || "\\");
return path;
}

Wyświetl plik

@ -208,20 +208,21 @@ define(function(require, exports, module) {
var reHome, reWorkspace, homeSub;
plugin.$initPaths = function(home, workspaceDir) {
reHome = new RegExp("^" + plugin.escapeRegExp(home) + "(/|/?$)");
var pre = c9.platform == "win32" ? "/?" : "";
reHome = new RegExp("^" + pre + plugin.escapeRegExp(home) + "(/|/?$)");
var wd = workspaceDir.replace(/\/?$/, "");
reWorkspace = new RegExp("^" + plugin.escapeRegExp(wd) + "(/|/?$)");
reWorkspace = new RegExp("^" + pre + plugin.escapeRegExp(wd) + "(/|/?$)");
homeSub = "~/";
if (home == workspaceDir) {
reHome = new RegExp("^(" + plugin.escapeRegExp(home) + "|~)(/|/?$)");
reHome = new RegExp("^(" + pre + plugin.escapeRegExp(home) + "|~)(/|/?$)");
homeSub = "/";
reWorkspace = null;
} else if (reHome.test(workspaceDir)) {
reWorkspace = new RegExp("^" +
reWorkspace = new RegExp("^" + pre +
plugin.escapeRegExp(workspaceDir.replace(reHome, "~/")) + "(/|/?$)"
);
} else if (reWorkspace.test(home)) {
reHome = new RegExp("^(" + plugin.escapeRegExp(home) + "|~)(/|/?$)");
reHome = new RegExp("^(" + pre + plugin.escapeRegExp(home) + "|~)(/|/?$)");
homeSub = home.replace(reWorkspace, "/").replace(/\/?$/, "/");
reWorkspace = null;
}

Wyświetl plik

@ -205,8 +205,7 @@ define(function(require, exports, module) {
}
// Make sure home dir is marked correctly
path = path.replace(reHome, "~");
if (path[0] != "/") path = "/" + path;
path = util.normalizePath(path);
fs.stat(path, function(err, stat) {
if (err) {

Wyświetl plik

@ -149,16 +149,16 @@ function plugin(options, imports, register) {
return next();
res.writeHead(200, {"Content-Type": "application/javascript"});
res.end("define(function(require, exports, module) { return '"
+ options.workspaceDir + "'; });");
res.end("define(function(require, exports, module) { return "
+ JSON.stringify(options.workspaceDir.replace(/\\/g, "/")) + "; });");
});
api.get("/vfs-home", function(req, res, next) {
if (!options.options.testing)
return next();
res.writeHead(200, {"Content-Type": "application/javascript"});
res.end("define(function(require, exports, module) { return '"
+ process.env.HOME + "'; });");
res.end("define(function(require, exports, module) { return "
+ JSON.stringify(process.env.HOME.replace(/\\/g, "/")) + "; });");
});
api.get("/update", function(req, res, next) {