changeset 18410:073fbe7e6a3a gui-release

Use native separatos in __fltk_getfile__ * liboctave/system/file-ops.cc, liboctave/system/file-ops.h (file_ops::native_separator_path): New function. * libinterp/dldfcn/__fltk_uigetfile__.cc (__fltk_uigetfile__): use file_ops::native_separator_path for returned file path.
author John Donoghue <john.donoghue@ieee.org>
date Wed, 29 Jan 2014 19:25:13 -0500
parents a9cec5517d92
children f74c6aaa6d0f
files libinterp/dldfcn/__fltk_uigetfile__.cc liboctave/system/file-ops.cc liboctave/system/file-ops.h
diffstat 3 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/__fltk_uigetfile__.cc	Wed Jan 29 15:28:13 2014 -0500
+++ b/libinterp/dldfcn/__fltk_uigetfile__.cc	Wed Jan 29 19:25:13 2014 -0500
@@ -123,10 +123,10 @@
         }
 
       if (multi_type == Fl_File_Chooser::DIRECTORY)
-        retval(0) = std::string (fc.value ());
+        retval(0) = file_ops::native_separator_path (std::string (fc.value ()));
       else
         {
-          retval(1) = std::string (fc.directory ()) + sep;
+          retval(1) = file_ops::native_separator_path (std::string (fc.directory ()) + sep);
           retval(2) = fc.filter_value () + 1;
         }
     }
--- a/liboctave/system/file-ops.cc	Wed Jan 29 15:28:13 2014 -0500
+++ b/liboctave/system/file-ops.cc	Wed Jan 29 19:25:13 2014 -0500
@@ -362,6 +362,25 @@
             : dir + dir_sep_char () + file);
 }
 
+std::string
+file_ops::native_separator_path(const std::string& path)
+{
+  std::string retval;
+  if (dir_sep_char() == '/')
+    retval = path;
+  else
+    {
+      int n = path.length ();
+      for (int  i = 0; i < n; i++)
+        {
+          if (path[i] == '/') 
+            retval += dir_sep_char();
+          else
+            retval += path[i];
+        }
+    }
+  return retval;
+}
 
 int
 octave_mkdir (const std::string& nm, mode_t md)
--- a/liboctave/system/file-ops.h	Wed Jan 29 15:28:13 2014 -0500
+++ b/liboctave/system/file-ops.h	Wed Jan 29 19:25:13 2014 -0500
@@ -95,6 +95,9 @@
     return path.substr (ipos);
   }
 
+  // convert path from UNIX type separators to whatever is the system separators
+  static std::string native_separator_path (const std::string& path);
+
 private:
 
   static file_ops *instance;