[chronojump] Ensure encoder url and videoURL '/' '\' are ok for current OS



commit 3e61f784319e20059cf0382e40e59e5165803296
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 28 02:58:59 2014 +0200

    Ensure encoder url and videoURL '/' '\' are ok for current OS

 src/sqlite/encoder.cs |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 255b350..ae6a6e7 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -231,12 +231,12 @@ class SqliteEncoder : Sqlite
                                        reader[6].ToString(),                   //extraWeight
                                        reader[7].ToString(),                   //signalOrCurve
                                        reader[8].ToString(),                   //filename
-                                       addURLpath(reader[9].ToString()),       //url
+                                       addURLpath(fixOSpath(reader[9].ToString())),    //url
                                        Convert.ToInt32(reader[10].ToString()), //time
                                        Convert.ToInt32(reader[11].ToString()), //minHeight
                                        reader[12].ToString(),                  //description
                                        reader[13].ToString(),                  //status
-                                       reader[14].ToString(),                  //videoURL
+                                       addURLpath(fixOSpath(reader[14].ToString())),   //videoURL
                                        econf,                                  //encoderConfiguration
                                        Util.ChangeDecimalSeparator(reader[16].ToString()),     //future1 
(meanPower on curves)
                                        reader[17].ToString(),                  //future2
@@ -415,6 +415,15 @@ class SqliteEncoder : Sqlite
                if( ! dbconOpened)
                        dbcon.Close();
        }
+       
+       //when select from database, ensure path separators are ok for this platform
+       //useful if person moved database between diff OS
+       private static string fixOSpath(string url) {
+               if(UtilAll.IsWindows())
+                       return url.Replace("/","\\");
+               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)


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