[chronojump] ForceSensor export: delete previous files is done by C#



commit b1cf5199dc2f279c5204d72288021fd6126b29da
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Feb 10 13:24:43 2021 +0100

    ForceSensor export: delete previous files is done by C#

 r-scripts/maximumIsometricForce.R | 12 +++---------
 src/forceSensor.cs                | 10 ++++++++++
 src/util.cs                       |  4 ++++
 3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index 3d94eef2..5c0faaab 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -1101,19 +1101,13 @@ if(op$singleOrMultiple == "TRUE")
        doProcess(dataFile, op$decimalChar, op$title, op$exercise, op$datetime, op$captureOptions, 
op$startSample, op$endSample)
 } else
 {
-       #0) prepare progressFolder to show feedback on chronojump
-       progressFolder = paste(tempPath, "/chronojump_mif_progress", sep ="")
-       print (paste("progressFolder", progressFolder))
-       if(dir.exists(progressFolder))
-               do.call(file.remove, list(list.files(progressFolder, full.names = TRUE)))
-       else
-               dir.create(progressFolder)
-
        #1) read the csv
         dataFiles = read.csv(file = paste(tempPath, "/maximumIsometricForceInputMulti.csv", sep=""), 
sep=";", stringsAsFactors=F)
        
        #2) call doProcess
-        for(i in 1:length(dataFiles[,1])) {
+       progressFolder = paste(tempPath, "/chronojump_mif_progress", sep ="")
+
+       for(i in 1:length(dataFiles[,1])) {
                print("fullURL")
                print(as.vector(dataFiles$fullURL[i]))
 
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 021eef60..5dfffab5 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -2330,6 +2330,16 @@ public class ForceSensorExport
                progressbar.Fraction = 0;
                notebook.CurrentPage = 1;
 
+               //create progressbar files dir or delete its contents
+               string dir = Util.GetForceSensorTempProgressDir();
+               if( ! Directory.Exists(dir))
+                       Directory.CreateDirectory (dir);
+               else {
+                       DirectoryInfo dirInfo = new DirectoryInfo(dir);
+                       foreach (FileInfo file in dirInfo.GetFiles())
+                               file.Delete();
+               }
+
                thread = new Thread (new ThreadStart (forceSensorExportDo));
                GLib.Idle.Add (new GLib.IdleHandler (pulseForceSensorExportGTK));
                thread.Start();
diff --git a/src/util.cs b/src/util.cs
index 7ce48e0e..ea03095d 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1067,6 +1067,10 @@ public class Util
                }
        }
 
+       public static string GetForceSensorTempProgressDir() {
+               return Path.Combine(Path.GetTempPath(), "chronojump_mif_progress");
+       }
+
        /*
         * <--------------- end of force sensor suff
         */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]