From 776a2c75360b1a376b2c22bcadce606030d8c75f Mon Sep 17 00:00:00 2001 From: amy Date: Thu, 23 Feb 2023 17:46:35 -0600 Subject: aa --- src/jssh.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/jssh.js') diff --git a/src/jssh.js b/src/jssh.js index 1da1f83..51c8562 100644 --- a/src/jssh.js +++ b/src/jssh.js @@ -84,14 +84,20 @@ class jssh { } add_file(fs, path, dir) { //console.log(fs, path); - if (path.length == 1) + if (path.length == 1){ + for(let o of fs){ + if(o.name == path[0]){ + path[0] += '-1' + return this.add_file(fs,path,dir) + } + } return fs.push({ name: path[0], perms: { r: true }, dir: dir, content: dir ? [] : "", }); - + } for (let f in fs) { if (fs[f].name == path[0] && fs[f].dir) { fs = fs[f].content; @@ -254,9 +260,7 @@ class jssh { : this.working_dir + "/" + stripped[1] ) .split("/") - .filter(function (e) { - return e !== ""; - }), + .filter(rem_emp), false ); @@ -270,9 +274,7 @@ class jssh { : this.working_dir + "/" + stripped[1] ) .split("/") - .filter(function (e) { - return e !== ""; - }) + .filter(rem_emp) ); break; case "mkdir": @@ -284,9 +286,7 @@ class jssh { : this.working_dir + "/" + stripped[1] ) .split("/") - .filter(function (e) { - return e !== ""; - }), + .filter(rem_emp), true ); break; @@ -469,9 +469,7 @@ class jssh { .trim(); pp = this.clean_path(pp[0] == "/" ? pp : this.working_dir + "/" + pp); - pp = pp.split("/").filter(function (e) { - return e !== ""; - }); + pp = pp.split("/").filter(rem_emp); this.write_file(this.fs, pp, history_write.trim(), redir_app); } else { document.getElementById(this.history).innerHTML += history_write; -- cgit v1.2.3