[chronojump] At force sensor load, check file is not empty.



commit f8a02d97111e560e40d7c74cd1143a1aded52915
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 17 14:13:39 2020 +0200

    At force sensor load, check file is not empty.

 src/constants.cs            | 4 ++++
 src/gui/app1/forceSensor.cs | 7 +++++++
 2 files changed, 11 insertions(+)
---
diff --git a/src/constants.cs b/src/constants.cs
index 36246cd9..ec00a547 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -866,6 +866,10 @@ public class Constants
        {
                return Catalog.GetString("Error. File not found.");
        }
+       public static string FileEmptyStr()
+       {
+               return Catalog.GetString("Error. File is empty.");
+       }
        public static string FileCopyProblemStr()
        {
                return Catalog.GetString("Error. Cannot copy file.");
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 6ec9a916..e45badef 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1509,6 +1509,13 @@ LogB.Information(" fs R ");
                        new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileNotFoundStr());
                        return;
                }
+               List<string> contents = Util.ReadFileAsStringList(fs.FullURL);
+               if(contents.Count < 3)
+               {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileEmptyStr());
+                       return;
+               }
+
 
                currentForceSensor = fs;
                lastForceSensorFile = Util.RemoveExtension(fs.Filename);


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