[chronojump] MakeURLabsolute / MakeURLrelative on util.cs



commit 331c370f0f44cf85f471c07a295fc6e28d810caf
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Sep 6 09:40:33 2019 +0200

    MakeURLabsolute / MakeURLrelative on util.cs

 src/sqlite/encoder.cs | 29 ++++++-----------------------
 src/util.cs           | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 4ef4394f..cf566194 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -86,10 +86,10 @@ class SqliteEncoder : Sqlite
                        es.exerciseID + ", \"" + es.eccon + "\", \"" +
                        es.LateralityToEnglish() + "\", \"" + Util.ConvertToPoint(es.extraWeight) + "\", \"" +
                        es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
-                       removeURLpath(es.url) + "\", " + 
+                       Util.MakeURLrelative(es.url) + "\", " +
                        es.time + ", " + es.minHeight + ", \"" + es.description + 
                        "\", \"" + es.status + "\", \"" + 
-                       removeURLpath(es.videoURL) + "\", \"" + 
+                       Util.MakeURLrelative(es.videoURL) + "\", \"" +
                        es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\", \"" +
                        Util.ConvertToPoint(es.future1) + "\", \"" + es.future2 + "\", \"" + es.future3 + 
"\")";
                LogB.SQL(dbcmd.CommandText.ToString());
@@ -134,12 +134,12 @@ class SqliteEncoder : Sqlite
                                "\", extraWeight = \"" + Util.ConvertToPoint(es.extraWeight) +
                                "\", signalOrCurve = \"" + es.signalOrCurve +
                                "\", filename = \"" + es.filename +
-                               "\", url = \"" + removeURLpath(es.url) +
+                               "\", url = \"" + Util.MakeURLrelative(es.url) +
                                "\", time = " + es.time +
                                ", minHeight = " + es.minHeight +
                                ", description = \"" + es.description + 
                                "\", status = \"" + es.status + 
-                               "\", videoURL = \"" + removeURLpath(es.videoURL) + 
+                               "\", videoURL = \"" + Util.MakeURLrelative(es.videoURL) +
                                "\", encoderConfiguration = \"" + 
es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) +
                                "\", future1 = \"" + Util.ConvertToPoint(es.future1) + 
                                "\", future2 = \"" + es.future2 + 
@@ -290,7 +290,7 @@ class SqliteEncoder : Sqlite
                        //if there's video, will be with full path
                        string videoURL = "";
                        if(reader[14].ToString() != "")
-                               videoURL = addURLpath(fixOSpath(reader[14].ToString()));
+                               videoURL = Util.MakeURLabsolute(fixOSpath(reader[14].ToString()));
                        
                        //LogB.SQL(econf.ToString(":", true));
                        eSQL = new EncoderSQL (
@@ -303,7 +303,7 @@ class SqliteEncoder : Sqlite
                                        Util.ChangeDecimalSeparator(reader[6].ToString()),      //extraWeight
                                        reader[7].ToString(),                   //signalOrCurve
                                        reader[8].ToString(),                   //filename
-                                       addURLpath(fixOSpath(reader[9].ToString())),    //url
+                                       Util.MakeURLabsolute(fixOSpath(reader[9].ToString())),  //url
                                        Convert.ToInt32(reader[10].ToString()), //time
                                        Convert.ToInt32(reader[11].ToString()), //minHeight
                                        reader[12].ToString(),                  //description
@@ -698,23 +698,6 @@ class SqliteEncoder : Sqlite
                else
                        return url.Replace("\\","/");
        }
-       //url and videoURL stored path is relative to be able to move data between computers
-       //then SELECT: makes it abolute (addURLpath)
-       //INSERT and UPDATE: makes it relative (removeURLpath)
-       private static string addURLpath(string url) {
-               string parentDir = Util.GetParentDir(true); //add final '/' or '\'
-               if( ! url.StartsWith(parentDir) )
-                       url = parentDir + url; 
-
-               return url;
-       }
-       private static string removeURLpath(string url) {
-               string parentDir = Util.GetParentDir(true); //add final '/' or '\'
-               if( url.StartsWith(parentDir) )
-                       url = url.Replace(parentDir, ""); 
-
-               return url;
-       }
 
 
        /*
diff --git a/src/util.cs b/src/util.cs
index 792309a2..76988635 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -869,6 +869,24 @@ public class Util
                return path;
        }
        
+       //url and videoURL stored path is relative to be able to move data between computers
+       //then SELECT: makes it abolute (addURLpath)
+       //INSERT and UPDATE: makes it relative (removeURLpath)
+       public static string MakeURLabsolute(string url) {
+               string parentDir = Util.GetParentDir(true); //add final '/' or '\'
+               if( ! url.StartsWith(parentDir) )
+                       url = parentDir + url;
+
+               return url;
+       }
+       public static string MakeURLrelative(string url) {
+               string parentDir = Util.GetParentDir(true); //add final '/' or '\'
+               if( url.StartsWith(parentDir) )
+                       url = url.Replace(parentDir, "");
+
+               return url;
+       }
+
        /********** end of LocalApplicationData path ************/
        
        /********** start of database paths ************/


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