Check if trimspNL found.

This commit is contained in:
Zaher Salman
2021-06-14 23:16:48 +02:00
parent 47a135b1ee
commit 27fbc380cb
2 changed files with 17 additions and 3 deletions
+11 -1
View File
@@ -17,7 +17,7 @@ function execute(command) {
}
function checkDir(directory) {
// Check whether director exists, if not create it
// Check whether directory exists, if not create it
if (!fs.existsSync(directory)) {
// Folder does not exist try to create it
fs.mkdir(directory,{recursive: true}, (err) => {
@@ -54,3 +54,13 @@ function readAsciiFile(filename) {
return(content);
}
function fileExists(filename) {
try {
if (fs.existsSync(filename)) {
return 1;
}
}catch(err) {
console.log(err);
}
return 0;
}
+6 -2
View File
@@ -934,7 +934,12 @@ function sum(array){
function startSequence(All) {
let cmd = '';
let trimBin = All['trimPath']+"/trimspNL";
// Check if the trimspNL binary is found
if (!fileExists(trimBin)) {
// if not found, try in PATH and hope for the best
trimBin = "trimspNL";
}
// Check if workPath exists otherwise create it
checkDir(All['workPath']); // from TrimSPelec.js, Electron/Node specific
@@ -1044,7 +1049,6 @@ function startSequence(All) {
writeAsciiFile(FILENAME+".inp", eingabe1);
Progress=20;
// Update progress on GUI
let path = process.env.PWD;
cmd = "cd "+All["workPath"]+";cp "+FILENAME+".inp eingabe1.inp;"+trimBin;
execute(cmd);
// document.getElementById("myBar").style.width = Progress + "%";