25 lines
629 B
JavaScript
25 lines
629 B
JavaScript
var Session = function(terminal) {
|
|
|
|
this.terminal = terminal;
|
|
|
|
this.homeDirectory = '/';
|
|
this.currentDirectory = this.homeDirectory;
|
|
|
|
};
|
|
|
|
Session.prototype.changeDirectory = function(path) {
|
|
if (path.charAt(0) == '/') {
|
|
this.currentDirectory = this.terminal.fs.toCanonicalPath(path);
|
|
} else {
|
|
this.currentDirectory = this.terminal.fs.toCanonicalPath(this.currentDirectory + '/' + path);
|
|
}
|
|
};
|
|
|
|
Session.prototype.toAbsolutePath = function(path) {
|
|
if (path.charAt(0) == '/') {
|
|
return this.terminal.fs.toCanonicalPath(path);
|
|
} else {
|
|
return this.terminal.fs.toCanonicalPath(this.currentDirectory + '/' + path);
|
|
}
|
|
};
|