changeset 16764:532ccee1b6f5

@ftp/cd.m: implement return of working directory
author Carnë Draug <carandraug@octave.org>
date Mon, 17 Jun 2013 23:19:12 +0100
parents 70ea511edbc4
children 80b9a9e1c965
files scripts/@ftp/cd.m
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/@ftp/cd.m	Sun Jun 16 12:07:19 2013 +0200
+++ b/scripts/@ftp/cd.m	Mon Jun 17 23:19:12 2013 +0100
@@ -17,12 +17,27 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
+## @deftypefn {Function File} {} cd (@var{f})
 ## @deftypefn {Function File} {} cd (@var{f}, @var{path})
-## Set the remote directory to @var{path} on the FTP connection @var{f}.
+## Get or sets the remote directory on the FTP connection @var{f}.
 ##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
+##
+## If @var{path} is not specified, returns the remote current working
+## directory.  Otherwise, sets the remote directory to @var{path} and
+## returns the new remote working directory.
+##
+## If the directory does not exist, an error message is printed and the
+## working directory is not changed.
 ## @end deftypefn
 
-function cd (f, path)
-  __ftp_cwd__ (f.curlhandle, path);
+function path = cd (f, path)
+  if (nargin != 1 && nargin != 2)
+    print_usage ();
+  endif
+
+  if (nargin == 2)
+    __ftp_cwd__ (f.curlhandle, path);
+  endif
+  path = __ftp_pwd__ (f.curlhandle);
 endfunction