view scripts/@ftp/loadobj.m @ 17548:92541ff4cc3c

improve implementation of ftp object handles * urlwrite.cc (curl_handles): Delete class. (handles): Delete static variable. (ch_manager): New class. (make_handle_fraction): New function. (F__ftp_pwd__, F__ftp_cwd__, F__ftp_dir__, F__ftp_ascii__, F__ftp_binary__, F__ftp_mode__, F__ftp_delete__, F__ftp_rmdir__, F__ftp_mkdir__, F__ftp_rename__, F__ftp_mput__, F__ftp_mget__): Find curl object corresponding to given handle using ch_manager instead of looking in handles map. (F__ftp__): Return handle instead of accepting it as argument. Change all uses.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Oct 2013 23:40:01 -0400
parents 1c89599167a6
children d63878346099
line wrap: on
line source

## Copyright (C) 2009-2012 David Bateman
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

function b = loadobj (a)
  b = a;
  if (isfield (b, "jobject"))
    b = rmfield (b, "jobject");
  endif
  b.curlhandle = __ftp__ (b.host, b.username, b.password);
  if (isfield (b, "dir"))
    if (! isempty (b.dir))
      __ftp_cwd__ (b.curlhandle, b.dir);
    endif
    b = rmfield (b, "dir");
  elseif (isfield (b, "remotePwd"))
    ## FIXME: Can we read matlab java stringBuffer objects?
    warning ("can not change remote directory in loaded FTP object");
    b = rmfield (b, "remotePwd");
  endif
endfunction