Fixed windows paths by using path.posix and replacing backslashes

This commit is contained in:
WebFreak001 2016-02-10 01:54:12 +01:00
commit 9570f9068f
2 changed files with 12 additions and 12 deletions

View file

@ -4,7 +4,8 @@ import { EventEmitter } from "events"
import { parseMI, MINode } from '../mi_parse';
import * as net from "net"
import * as fs from "fs"
import * as path from "path"
import { posix } from "path"
let path = posix;
var Client = require("ssh2").Client;
function escape(str: string) {
@ -25,8 +26,8 @@ export class MI2 extends EventEmitter implements IBackend {
}
load(cwd: string, target: string): Thenable<any> {
if (!path.isAbsolute(target))
target = path.join(cwd, target);
if (!path.isAbsolute(target.replace(/\\/g, "/")))
target = path.join(cwd.replace(/\\/g, "/"), target.replace(/\\/g, "/"));
return new Promise((resolve, reject) => {
this.isSSH = false;
this.process = ChildProcess.spawn(this.application, this.preargs.concat([target]), { cwd: cwd });
@ -45,9 +46,6 @@ export class MI2 extends EventEmitter implements IBackend {
ssh(args: SSHArguments, cwd: string, target: string): Thenable<any> {
return new Promise((resolve, reject) => {
if (!path.isAbsolute(target))
target = path.join(cwd, target);
this.isSSH = true;
this.sshReady = false;
this.sshConn = new Client();

View file

@ -4,7 +4,10 @@ import { Breakpoint, IBackend, SSHArguments } from './backend/backend'
import { MINode } from './backend/mi_parse'
import { expandValue, isExpandable } from './backend/gdb_expansion'
import { MI2 } from './backend/mi2/mi2'
import { relative, resolve } from "path"
import { posix } from "path"
let resolve = posix.resolve;
let relative = posix.relative;
export interface LaunchRequestArguments {
cwd: string;
@ -163,10 +166,9 @@ class MI2DebugSession extends DebugSession {
this.gdbDebugger.clearBreakPoints().then(() => {
let path = args.source.path;
if (this.isSSH) {
path = relative(this.trimCWD, path);
path = resolve(this.switchCWD, path);
path = relative(this.trimCWD.replace(/\\/g, "/"), path.replace(/\\/g, "/"));
path = resolve(this.switchCWD.replace(/\\/g, "/"), path.replace(/\\/g, "/"));
}
this.handleMsg("console", "Breakpoints for file " + path + "\n");
let all = [];
args.breakpoints.forEach(brk => {
all.push(this.gdbDebugger.addBreakPoint({ file: path, line: brk.line, condition: brk.condition }));
@ -194,8 +196,8 @@ class MI2DebugSession extends DebugSession {
stack.forEach(element => {
let file = element.file;
if (this.isSSH) {
file = relative(this.switchCWD, file);
file = resolve(this.trimCWD, file);
file = relative(this.switchCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
file = resolve(this.trimCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
}
ret.push(new StackFrame(element.level, element.function + "@" + element.address, new Source(element.fileName, file), element.line, 0));
});