changeset 21897:39afd54c2981

perform tilde expansion for more file and directory functions * dirfns.cc (Freaddir, Flink, Fsymlink, Freadlink, Frename): Perform tilde expansion on filename arguments.
author John W. Eaton <jwe@octave.org>
date Tue, 14 Jun 2016 13:23:29 -0400
parents 83c824c727c9
children b5313b6cbe72
files libinterp/corefcn/dirfns.cc
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/dirfns.cc	Tue Jun 14 12:51:55 2016 -0400
+++ b/libinterp/corefcn/dirfns.cc	Tue Jun 14 13:23:29 2016 -0400
@@ -179,6 +179,8 @@
 
   octave_value_list retval = ovl (Cell (), -1.0, "");
 
+  dirname = octave::sys::file_ops::tilde_expand (dirname);
+
   octave::sys::dir_entry dir (dirname);
 
   if (dir)
@@ -315,6 +317,9 @@
   std::string from = args(0).xstring_value ("link: OLD must be a string");
   std::string to = args(1).xstring_value ("link: NEW must be a string");
 
+  from = octave::sys::file_ops::tilde_expand (from);
+  to = octave::sys::file_ops::tilde_expand (to);
+
   std::string msg;
 
   int status = octave::sys::link (from, to, msg);
@@ -343,6 +348,9 @@
   std::string from = args(0).xstring_value ("symlink: OLD must be a string");
   std::string to = args(1).xstring_value ("symlink: NEW must be a string");
 
+  from = octave::sys::file_ops::tilde_expand (from);
+  to = octave::sys::file_ops::tilde_expand (to);
+
   std::string msg;
 
   int status = octave::sys::symlink (from, to, msg);
@@ -371,6 +379,8 @@
 
   std::string symlink = args(0).xstring_value ("readlink: SYMLINK must be a string");
 
+  symlink = octave::sys::file_ops::tilde_expand (symlink);
+
   std::string result, msg;
 
   int status = octave::sys::readlink (symlink, result, msg);
@@ -399,6 +409,9 @@
   std::string from = args(0).xstring_value ("rename: OLD must be a string");
   std::string to = args(1).xstring_value ("rename: NEW must be a string");
 
+  from = octave::sys::file_ops::tilde_expand (from);
+  to = octave::sys::file_ops::tilde_expand (to);
+
   std::string msg;
 
   int status = octave::sys::rename (from, to, msg);