26 #if defined (HAVE_CONFIG_H)
64 int nargin = args.length ();
66 std::string host = args(0).xstring_value (
"__ftp__: HOST must be a string");
68 std::string user = (nargin > 1)
69 ? args(1).xstring_value (
"__ftp__: USER must be a string")
72 std::string passwd = (nargin > 2)
73 ? args(2).xstring_value (
"__ftp__: PASSWD must be a string")
94 error (
"__ftp_pwd__: invalid ftp handle");
96 return ovl (url_xfer.
pwd ());
105 std::string path =
"";
106 if (args.length () > 1)
107 path = args(1).xstring_value (
"__ftp_cwd__: PATH must be a string");
114 error (
"__ftp_cwd__: invalid ftp handle");
121 DEFMETHOD (__ftp_dir__, interp, args, nargout,
133 error (
"__ftp_dir__: invalid ftp handle");
175 fileisdir(i) = fisdir;
176 time_t ftime_t = ftime;
177 filectime(i) = ctime (&ftime_t);
179 filedatenum(i) = double (ftime);
182 st.
assign (
"date", filectime);
183 st.
assign (
"bytes", filesize);
184 st.
assign (
"isdir", fileisdir);
185 st.
assign (
"datenum", filedatenum);
194 DEFMETHOD (__ftp_ascii__, interp, args, ,
205 error (
"__ftp_ascii__: invalid ftp handle");
212 DEFMETHOD (__ftp_binary__, interp, args, ,
223 error (
"__ftp_binary__: invalid ftp handle");
230 DEFMETHOD (__ftp_close__, interp, args, ,
241 error (
"__ftp_close__: invalid ftp handle");
259 error (
"__ftp_binary__: invalid ftp handle");
261 return ovl (url_xfer.
is_ascii () ?
"ascii" :
"binary");
264 DEFMETHOD (__ftp_delete__, interp, args, ,
270 std::string file = args(1).xstring_value (
"__ftp_delete__: FILE must be a string");
277 error (
"__ftp_delete__: invalid ftp handle");
284 DEFMETHOD (__ftp_rmdir__, interp, args, ,
290 std::string dir = args(1).xstring_value (
"__ftp_rmdir__: DIR must be a string");
297 error (
"__ftp_rmdir__: invalid ftp handle");
299 url_xfer.
rmdir (dir);
304 DEFMETHOD (__ftp_mkdir__, interp, args, ,
310 std::string dir = args(1).xstring_value (
"__ftp_mkdir__: DIR must be a string");
317 error (
"__ftp_mkdir__: invalid ftp handle");
319 url_xfer.
mkdir (dir);
324 DEFMETHOD (__ftp_rename__, interp, args, ,
330 std::string oldname = args(1).xstring_value (
"__ftp_rename__: OLDNAME must be a string");
331 std::string newname = args(2).xstring_value (
"__ftp_rename__: NEWNAME must be a string");
338 error (
"__ftp_rename__: invalid ftp handle");
340 url_xfer.
rename (oldname, newname);
345 DEFMETHOD (__ftp_mput__, interp, args, nargout,
352 std::string pat = args(1).xstring_value (
"__ftp_mput__: PATTERN must be a string");
359 error (
"__ftp_mput__: invalid ftp handle");
368 std::string file = files(i);
371 error (
"__ftp__mput: file does not exist");
377 if (! url_xfer.
good ())
385 std::ios::in | std::ios::binary);
387 if (! ifile.is_open ())
388 error (
"__ftp_mput__: unable to open file");
390 url_xfer.
put (file, ifile);
394 if (! url_xfer.
good ())
402 return ovl (file_list);
414 std::string file = args(1).xstring_value (
"__ftp_mget__: PATTERN must be a string");
418 if (args.length () == 3 && ! args(2).isempty ())
419 target = args(2).xstring_value (
"__ftp_mget__: TARGET must be a string")
427 error (
"__ftp_mget__: invalid ftp handle");
435 if (pattern.
match (sv(i)))
451 std::ios::out | std::ios::binary);
453 if (! ofile.is_open ())
454 error (
"__ftp_mget__: unable to open file");
456 int(*unlink_fptr)(
const std::string&) =
sys::unlink;
459 url_xfer.
get (sv(i), ofile);
463 if (url_xfer.
good ())
467 if (! url_xfer.
good ())
473 error (
"__ftp_mget__: file not found");
478 OCTAVE_END_NAMESPACE(
octave)
Vector representing the dimensions (size) of an Array.
string_vector glob() const
bool match(const std::string &str) const
void assign(const std::string &k, const Cell &val)
string_vector & append(const std::string &s)
octave_idx_type numel() const
void free(const url_handle &h)
url_handle make_url_handle(const std::string &host, const std::string &user, const std::string &passwd, std::ostream &os)
url_handle lookup(double val)
url_transfer get_object(double val)
void put(const std::string &file, std::istream &is)
void get_fileinfo(const std::string &filename, double &filesize, OCTAVE_TIME_T &filetime, bool &fileisdir)
void get(const std::string &file, std::ostream &os)
void cwd(const std::string &path)
void mkdir(const std::string &path)
string_vector mput_directory(const std::string &base, const std::string &directory)
std::string lasterror() const
void mget_directory(const std::string &directory, const std::string &target)
void rmdir(const std::string &path)
void del(const std::string &file)
void rename(const std::string &oldname, const std::string &newname)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void() error(const char *fmt,...)
std::string dir_sep_str()
bool dir_exists(const std::string &dirname)
bool file_exists(const std::string &filename, bool is_dir)
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
std::string tilde_expand(const std::string &name)
int unlink(const std::string &name)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.