GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
urlwrite.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2006-2018 Alexander Barth
4 Copyright (C) 2009 David Bateman
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 // Author: Alexander Barth <abarth@marine.usf.edu>
25 // Adapted-By: jwe
26 
27 #if defined (HAVE_CONFIG_H)
28 # include "config.h"
29 #endif
30 
31 #include <string>
32 #include <fstream>
33 #include <iomanip>
34 #include <iostream>
35 
36 #include "dir-ops.h"
37 #include "file-ops.h"
38 #include "file-stat.h"
39 #include "oct-env.h"
40 #include "oct-handle.h"
41 #include "glob-match.h"
42 #include "url-transfer.h"
43 
44 #include "defun.h"
45 #include "error.h"
46 #include "interpreter.h"
47 #include "oct-map.h"
48 #include "oct-refcount.h"
49 #include "ov-cell.h"
50 #include "ovl.h"
51 #include "pager.h"
52 #include "unwind-prot.h"
53 #include "url-handle-manager.h"
54 
55 static void
57 {
59 }
60 
61 DEFUN (urlwrite, args, nargout,
62  doc: /* -*- texinfo -*-
63 @deftypefn {} {} urlwrite (@var{url}, @var{localfile})
64 @deftypefnx {} {@var{f} =} urlwrite (@var{url}, @var{localfile})
65 @deftypefnx {} {[@var{f}, @var{success}] =} urlwrite (@var{url}, @var{localfile})
66 @deftypefnx {} {[@var{f}, @var{success}, @var{message}] =} urlwrite (@var{url}, @var{localfile})
67 Download a remote file specified by its @var{url} and save it as
68 @var{localfile}.
69 
70 For example:
71 
72 @example
73 @group
74 urlwrite ("ftp://ftp.octave.org/pub/README",
75  "README.txt");
76 @end group
77 @end example
78 
79 The full path of the downloaded file is returned in @var{f}.
80 
81 The variable @var{success} is 1 if the download was successful,
82 otherwise it is 0 in which case @var{message} contains an error message.
83 
84 If no output argument is specified and an error occurs, then the error is
85 signaled through Octave's error handling mechanism.
86 
87 This function uses libcurl. Curl supports, among others, the HTTP, FTP, and
88 FILE protocols. Username and password may be specified in the URL, for
89 example:
90 
91 @example
92 @group
93 urlwrite ("http://username:password@@example.com/file.txt",
94  "file.txt");
95 @end group
96 @end example
97 
98 GET and POST requests can be specified by @var{method} and @var{param}.
99 The parameter @var{method} is either @samp{get} or @samp{post} and
100 @var{param} is a cell array of parameter and value pairs.
101 For example:
102 
103 @example
104 @group
105 urlwrite ("http://www.google.com/search", "search.html",
106  "get", @{"query", "octave"@});
107 @end group
108 @end example
109 @seealso{urlread}
110 @end deftypefn */)
111 {
112  int nargin = args.length ();
113 
114  // verify arguments
115  if (nargin != 2 && nargin != 4)
116  print_usage ();
117 
118  std::string url = args(0).xstring_value ("urlwrite: URL must be a string");
119 
120  // name to store the file if download is successful
121  std::string filename = args(1).xstring_value ("urlwrite: LOCALFILE must be a string");
122 
125 
126  if (nargin == 4)
127  {
128  method = args(2).xstring_value ("urlwrite: METHOD must be a string");
129 
130  if (method != "get" && method != "post")
131  error (R"(urlwrite: METHOD must be "get" or "post")");
132 
133  param = args(3).xcellstr_value ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of strings");
134 
135  if (param.numel () % 2 == 1)
136  error ("urlwrite: number of elements in PARAM must be even");
137  }
138 
139  // The file should only be deleted if it doesn't initially exist, we
140  // create it, and the download fails. We use unwind_protect to do
141  // it so that the deletion happens no matter how we exit the function.
142 
144 
145  std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary);
146 
147  if (! ofile.is_open ())
148  error ("urlwrite: unable to open file");
149 
151 
153 
154  octave::url_transfer url_xfer (url, ofile);
155 
157 
158  if (! url_xfer.is_valid ())
159  error ("support for URL transfers was disabled when Octave was built");
160 
161  url_xfer.http_action (param, method);
162 
163  ofile.close ();
164 
165  if (url_xfer.good ())
166  frame.discard ();
167 
168  if (nargout > 0)
169  {
170  if (url_xfer.good ())
172  else
173  retval = ovl ("", false, url_xfer.lasterror ());
174  }
175 
176  if (nargout < 2 && ! url_xfer.good ())
177  error ("urlwrite: %s", url_xfer.lasterror ().c_str ());
178 
179  return retval;
180 }
181 
182 DEFUN (urlread, args, nargout,
183  doc: /* -*- texinfo -*-
184 @deftypefn {} {@var{s} =} urlread (@var{url})
185 @deftypefnx {} {[@var{s}, @var{success}] =} urlread (@var{url})
186 @deftypefnx {} {[@var{s}, @var{success}, @var{message}] =} urlread (@var{url})
187 @deftypefnx {} {[@dots{}] =} urlread (@var{url}, @var{method}, @var{param})
188 Download a remote file specified by its @var{url} and return its content
189 in string @var{s}.
190 
191 For example:
192 
193 @example
194 s = urlread ("ftp://ftp.octave.org/pub/README");
195 @end example
196 
197 The variable @var{success} is 1 if the download was successful,
198 otherwise it is 0 in which case @var{message} contains an error
199 message.
200 
201 If no output argument is specified and an error occurs, then the error is
202 signaled through Octave's error handling mechanism.
203 
204 This function uses libcurl. Curl supports, among others, the HTTP, FTP, and
205 FILE protocols. Username and password may be specified in the URL@. For
206 example:
207 
208 @example
209 s = urlread ("http://user:password@@example.com/file.txt");
210 @end example
211 
212 GET and POST requests can be specified by @var{method} and @var{param}.
213 The parameter @var{method} is either @samp{get} or @samp{post} and
214 @var{param} is a cell array of parameter and value pairs.
215 For example:
216 
217 @example
218 @group
219 s = urlread ("http://www.google.com/search", "get",
220  @{"query", "octave"@});
221 @end group
222 @end example
223 @seealso{urlwrite}
224 @end deftypefn */)
225 {
226  int nargin = args.length ();
227 
228  // verify arguments
229  if (nargin != 1 && nargin != 3)
230  print_usage ();
231 
232  std::string url = args(0).xstring_value ("urlread: URL must be a string");
233 
236 
237  if (nargin == 3)
238  {
239  method = args(1).xstring_value ("urlread: METHOD must be a string");
240 
241  if (method != "get" && method != "post")
242  error (R"(urlread: METHOD must be "get" or "post")");
243 
244  param = args(2).xcellstr_value ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of strings");
245 
246  if (param.numel () % 2 == 1)
247  error ("urlread: number of elements in PARAM must be even");
248  }
249 
250  std::ostringstream buf;
251 
253 
254  if (! url_xfer.is_valid ())
255  error ("support for URL transfers was disabled when Octave was built");
256 
257  url_xfer.http_action (param, method);
258 
260 
261  if (nargout > 0)
262  {
263  // Return empty string if no error occurred.
264  retval = ovl (buf.str (), url_xfer.good (),
265  url_xfer.good () ? "" : url_xfer.lasterror ());
266  }
267 
268  if (nargout < 2 && ! url_xfer.good ())
269  error ("urlread: %s", url_xfer.lasterror ().c_str ());
270 
271  return retval;
272 }
273 
274 DEFMETHOD (__ftp__, interp, args, ,
275  doc: /* -*- texinfo -*-
276 @deftypefn {} {@var{handle} =} __ftp__ (@var{host})
277 @deftypefnx {} {@var{handle} =} __ftp__ (@var{host}, @var{username}, @var{password})
278 Undocumented internal function
279 @end deftypefn */)
280 {
281  int nargin = args.length ();
282 
284  print_usage ();
285 
286  std::string host = args(0).xstring_value ("__ftp__: HOST must be a string");
287 
288  std::string user = (nargin > 1)
289  ? args(1).xstring_value ("__ftp__: USER must be a string")
290  : "anonymous";
291 
292  std::string passwd = (nargin > 2)
293  ? args(2).xstring_value ("__ftp__: PASSWD must be a string")
294  : "";
295 
296  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
297 
298  octave::url_handle uh = uhm.make_url_handle (host, user, passwd,
299  octave_stdout);
300 
301  return ovl (uh.value ());
302 }
303 
304 DEFMETHOD (__ftp_pwd__, interp, args, ,
305  doc: /* -*- texinfo -*-
306 @deftypefn {} {} __ftp_pwd__ (@var{handle})
307 Undocumented internal function
308 @end deftypefn */)
309 {
310  if (args.length () != 1)
311  error ("__ftp_pwd__: incorrect number of arguments");
312 
313  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
314 
315  octave::url_transfer url_xfer = uhm.get_object (args(0));
316 
317  if (! url_xfer.is_valid ())
318  error ("__ftp_pwd__: invalid ftp handle");
319 
320  return ovl (url_xfer.pwd ());
321 }
322 
323 DEFMETHOD (__ftp_cwd__, interp, args, ,
324  doc: /* -*- texinfo -*-
325 @deftypefn {} {} __ftp_cwd__ (@var{handle}, @var{path})
326 Undocumented internal function
327 @end deftypefn */)
328 {
329  int nargin = args.length ();
330 
331  if (nargin != 1 && nargin != 2)
332  error ("__ftp_cwd__: incorrect number of arguments");
333 
334  std::string path = "";
335  if (nargin > 1)
336  path = args(1).xstring_value ("__ftp_cwd__: PATH must be a string");
337 
338  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
339 
340  octave::url_transfer url_xfer = uhm.get_object (args(0));
341 
342  if (! url_xfer.is_valid ())
343  error ("__ftp_cwd__: invalid ftp handle");
344 
345  url_xfer.cwd (path);
346 
347  return ovl ();
348 }
349 
350 DEFMETHOD (__ftp_dir__, interp, args, nargout,
351  doc: /* -*- texinfo -*-
352 @deftypefn {} {} __ftp_dir__ (@var{handle})
353 Undocumented internal function
354 @end deftypefn */)
355 {
356  if (args.length () != 1)
357  error ("__ftp_dir__: incorrect number of arguments");
358 
359  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
360 
361  octave::url_transfer url_xfer = uhm.get_object (args(0));
362 
363  if (! url_xfer.is_valid ())
364  error ("__ftp_dir__: invalid ftp handle");
365 
367 
368  if (nargout == 0)
369  url_xfer.dir ();
370  else
371  {
372  string_vector sv = url_xfer.list ();
373  octave_idx_type n = sv.numel ();
374 
375  if (n == 0)
376  {
377  string_vector flds (5);
378 
379  flds(0) = "name";
380  flds(1) = "date";
381  flds(2) = "bytes";
382  flds(3) = "isdir";
383  flds(4) = "datenum";
384 
385  retval = octave_map (flds);
386  }
387  else
388  {
389  octave_map st;
390 
391  Cell filectime (dim_vector (n, 1));
392  Cell filesize (dim_vector (n, 1));
393  Cell fileisdir (dim_vector (n, 1));
394  Cell filedatenum (dim_vector (n, 1));
395 
396  st.assign ("name", Cell (sv));
397 
398  for (octave_idx_type i = 0; i < n; i++)
399  {
400  time_t ftime;
401  bool fisdir;
402  double fsize;
403 
404  url_xfer.get_fileinfo (sv(i), fsize, ftime, fisdir);
405 
406  fileisdir (i) = fisdir;
407  filectime (i) = ctime (&ftime);
408  filesize (i) = fsize;
409  filedatenum (i) = double (ftime);
410  }
411 
412  st.assign ("date", filectime);
413  st.assign ("bytes", filesize);
414  st.assign ("isdir", fileisdir);
415  st.assign ("datenum", filedatenum);
416 
417  retval = st;
418  }
419  }
420 
421  return retval;
422 }
423 
424 DEFMETHOD (__ftp_ascii__, interp, args, ,
425  doc: /* -*- texinfo -*-
426 @deftypefn {} {} __ftp_ascii__ (@var{handle})
427 Undocumented internal function
428 @end deftypefn */)
429 {
430  if (args.length () != 1)
431  error ("__ftp_ascii__: incorrect number of arguments");
432 
433  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
434 
435  octave::url_transfer url_xfer = uhm.get_object (args(0));
436 
437  if (! url_xfer.is_valid ())
438  error ("__ftp_ascii__: invalid ftp handle");
439 
440  url_xfer.ascii ();
441 
442  return ovl ();
443 }
444 
445 DEFMETHOD (__ftp_binary__, interp, args, ,
446  doc: /* -*- texinfo -*-
447 @deftypefn {} {} __ftp_binary__ (@var{handle})
448 Undocumented internal function
449 @end deftypefn */)
450 {
451  if (args.length () != 1)
452  error ("__ftp_binary__: incorrect number of arguments");
453 
454  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
455 
456  octave::url_transfer url_xfer = uhm.get_object (args(0));
457 
458  if (! url_xfer.is_valid ())
459  error ("__ftp_binary__: invalid ftp handle");
460 
461  url_xfer.binary ();
462 
463  return ovl ();
464 }
465 
466 DEFMETHOD (__ftp_close__, interp, args, ,
467  doc: /* -*- texinfo -*-
468 @deftypefn {} {} __ftp_close__ (@var{handle})
469 Undocumented internal function
470 @end deftypefn */)
471 {
472  if (args.length () != 1)
473  error ("__ftp_close__: incorrect number of arguments");
474 
475  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
476 
477  octave::url_handle h = uhm.lookup (args(0));
478 
479  if (! h.ok ())
480  error ("__ftp_close__: invalid ftp handle");
481 
482  uhm.free (h);
483 
484  return ovl ();
485 }
486 
487 DEFMETHOD (__ftp_mode__, interp, args, ,
488  doc: /* -*- texinfo -*-
489 @deftypefn {} {} __ftp_mode__ (@var{handle})
490 Undocumented internal function
491 @end deftypefn */)
492 {
493  if (args.length () != 1)
494  error ("__ftp_mode__: incorrect number of arguments");
495 
496  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
497 
498  octave::url_transfer url_xfer = uhm.get_object (args(0));
499 
500  if (! url_xfer.is_valid ())
501  error ("__ftp_binary__: invalid ftp handle");
502 
503  return ovl (url_xfer.is_ascii () ? "ascii" : "binary");
504 }
505 
506 DEFMETHOD (__ftp_delete__, interp, args, ,
507  doc: /* -*- texinfo -*-
508 @deftypefn {} {} __ftp_delete__ (@var{handle}, @var{path})
509 Undocumented internal function
510 @end deftypefn */)
511 {
512  if (args.length () != 2)
513  error ("__ftp_delete__: incorrect number of arguments");
514 
515  std::string file = args(1).xstring_value ("__ftp_delete__: FILE must be a string");
516 
517  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
518 
519  octave::url_transfer url_xfer = uhm.get_object (args(0));
520 
521  if (! url_xfer.is_valid ())
522  error ("__ftp_delete__: invalid ftp handle");
523 
524  url_xfer.del (file);
525 
526  return ovl ();
527 }
528 
529 DEFMETHOD (__ftp_rmdir__, interp, args, ,
530  doc: /* -*- texinfo -*-
531 @deftypefn {} {} __ftp_rmdir__ (@var{handle}, @var{path})
532 Undocumented internal function
533 @end deftypefn */)
534 {
535  if (args.length () != 2)
536  error ("__ftp_rmdir__: incorrect number of arguments");
537 
538  std::string dir = args(1).xstring_value ("__ftp_rmdir__: DIR must be a string");
539 
540  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
541 
542  octave::url_transfer url_xfer = uhm.get_object (args(0));
543 
544  if (! url_xfer.is_valid ())
545  error ("__ftp_rmdir__: invalid ftp handle");
546 
547  url_xfer.rmdir (dir);
548 
549  return ovl ();
550 }
551 
552 DEFMETHOD (__ftp_mkdir__, interp, args, ,
553  doc: /* -*- texinfo -*-
554 @deftypefn {} {} __ftp_mkdir__ (@var{handle}, @var{path})
555 Undocumented internal function
556 @end deftypefn */)
557 {
558  if (args.length () != 2)
559  error ("__ftp_mkdir__: incorrect number of arguments");
560 
561  std::string dir = args(1).xstring_value ("__ftp_mkdir__: DIR must be a string");
562 
563  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
564 
565  octave::url_transfer url_xfer = uhm.get_object (args(0));
566 
567  if (! url_xfer.is_valid ())
568  error ("__ftp_mkdir__: invalid ftp handle");
569 
570  url_xfer.mkdir (dir);
571 
572  return ovl ();
573 }
574 
575 DEFMETHOD (__ftp_rename__, interp, args, ,
576  doc: /* -*- texinfo -*-
577 @deftypefn {} {} __ftp_rename__ (@var{handle}, @var{path})
578 Undocumented internal function
579 @end deftypefn */)
580 {
581  if (args.length () != 3)
582  error ("__ftp_rename__: incorrect number of arguments");
583 
584  std::string oldname = args(1).xstring_value ("__ftp_rename__: OLDNAME must be a string");
585  std::string newname = args(2).xstring_value ("__ftp_rename__: NEWNAME must be a string");
586 
587  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
588 
589  octave::url_transfer url_xfer = uhm.get_object (args(0));
590 
591  if (url_xfer.is_valid ())
592  error ("__ftp_rename__: invalid ftp handle");
593 
594  url_xfer.rename (oldname, newname);
595 
596  return ovl ();
597 }
598 
599 DEFMETHOD (__ftp_mput__, interp, args, nargout,
600  doc: /* -*- texinfo -*-
601 @deftypefn {} {} __ftp_mput__ (@var{handle}, @var{files})
602 Undocumented internal function
603 @end deftypefn */)
604 {
605  if (args.length () != 2)
606  error ("__ftp_mput__: incorrect number of arguments");
607 
608  std::string pat = args(1).xstring_value ("__ftp_mput__: PATTERN must be a string");
609 
610  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
611 
612  octave::url_transfer url_xfer = uhm.get_object (args(0));
613 
614  if (! url_xfer.is_valid ())
615  error ("__ftp_mput__: invalid ftp handle");
616 
617  string_vector file_list;
618 
620  string_vector files = pattern.glob ();
621 
622  for (octave_idx_type i = 0; i < files.numel (); i++)
623  {
624  std::string file = files(i);
625 
627 
628  if (! fs.exists ())
629  error ("__ftp__mput: file does not exist");
630 
631  if (fs.is_dir ())
632  {
633  file_list.append (url_xfer.mput_directory ("", file));
634 
635  if (! url_xfer.good ())
636  error ("__ftp_mput__: %s", url_xfer.lasterror ().c_str ());
637  }
638  else
639  {
640  // FIXME: Does ascii mode need to be flagged here?
641  std::ifstream ifile (file.c_str (), std::ios::in | std::ios::binary);
642 
643  if (! ifile.is_open ())
644  error ("__ftp_mput__: unable to open file");
645 
646  url_xfer.put (file, ifile);
647 
648  ifile.close ();
649 
650  if (! url_xfer.good ())
651  error ("__ftp_mput__: %s", url_xfer.lasterror ().c_str ());
652 
653  file_list.append (file);
654  }
655  }
656 
657  if (nargout > 0)
658  return ovl (file_list);
659  else
660  return ovl ();
661 }
662 
663 DEFMETHOD (__ftp_mget__, interp, args, ,
664  doc: /* -*- texinfo -*-
665 @deftypefn {} {} __ftp_mget__ (@var{handle}, @var{pattern})
666 @deftypefnx {} {} __ftp_mget__ (@var{handle}, @var{pattern}, @var{target})
667 Undocumented internal function
668 @end deftypefn */)
669 {
670  int nargin = args.length ();
671 
672  if (nargin != 2 && nargin != 3)
673  error ("__ftp_mget__: incorrect number of arguments");
674 
675  std::string file = args(1).xstring_value ("__ftp_mget__: PATTERN must be a string");
676 
677  std::string target;
678 
679  if (nargin == 3 && ! args(2).isempty ())
680  target = args(2).xstring_value ("__ftp_mget__: TARGET must be a string") + octave::sys::file_ops::dir_sep_str ();
681 
682  octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
683 
684  octave::url_transfer url_xfer = uhm.get_object (args(0));
685 
686  if (! url_xfer.is_valid ())
687  error ("__ftp_mget__: invalid ftp handle");
688 
689  string_vector sv = url_xfer.list ();
690  octave_idx_type n = 0;
692 
693  for (octave_idx_type i = 0; i < sv.numel (); i++)
694  {
695  if (pattern.match (sv(i)))
696  {
697  n++;
698 
699  time_t ftime;
700  bool fisdir;
701  double fsize;
702 
703  url_xfer.get_fileinfo (sv(i), fsize, ftime, fisdir);
704 
705  if (fisdir)
706  url_xfer.mget_directory (sv(i), target);
707  else
708  {
709  std::ofstream ofile ((target + sv(i)).c_str (),
710  std::ios::out |
711  std::ios::binary);
712 
713  if (! ofile.is_open ())
714  error ("__ftp_mget__: unable to open file");
715 
717 
718  frame.add_fcn (delete_file, target + sv(i));
719 
720  url_xfer.get (sv(i), ofile);
721 
722  ofile.close ();
723 
724  if (url_xfer.good ())
725  frame.discard ();
726  }
727 
728  if (! url_xfer.good ())
729  error ("__ftp_mget__: %s", url_xfer.lasterror().c_str());
730  }
731  }
732 
733  if (n == 0)
734  error ("__ftp_mget__: file not found");
735 
736  return ovl ();
737 }
url_handle make_url_handle(const std::string &host, const std::string &user, const std::string &passwd, std::ostream &os)
bool is_valid(void) const
Definition: url-transfer.h:185
Definition: Cell.h:37
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:135
string_vector list(void)
Definition: url-transfer.h:246
void assign(const std::string &k, const Cell &val)
Definition: oct-map.h:351
double value(void) const
Definition: oct-handle.h:74
url_handle lookup(double val)
std::string lasterror(void) const
Definition: url-transfer.h:189
int unlink(const std::string &name)
Definition: file-ops.cc:618
OCTINTERP_API void print_usage(void)
Definition: defun.cc:54
void mkdir(const std::string &path)
Definition: url-transfer.h:215
void rename(const std::string &oldname, const std::string &newname)
Definition: url-transfer.h:217
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:276
void add_fcn(void(*fcn)(void))
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:53
void error(const char *fmt,...)
Definition: error.cc:578
std::string filename
Definition: urlwrite.cc:121
void put(const std::string &file, std::istream &is)
Definition: url-transfer.h:222
bool is_dir(void) const
Definition: file-stat.cc:57
std::string dir_sep_str(void)
Definition: file-ops.cc:233
void mget_directory(const std::string &directory, const std::string &target)
Definition: url-transfer.h:232
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
Definition: oct-env.cc:129
double h
Definition: graphics.cc:11808
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:997
bool good(void) const
Definition: url-transfer.h:187
string_vector mput_directory(const std::string &base, const std::string &directory)
Definition: url-transfer.h:238
void free(const url_handle &h)
string_vector & append(const std::string &s)
Definition: str-vec.cc:107
octave_value retval
Definition: data.cc:6246
void rmdir(const std::string &path)
Definition: url-transfer.h:213
void get_fileinfo(const std::string &filename, double &filesize, time_t &filetime, bool &fileisdir)
Definition: url-transfer.h:248
Array< std::string > param
Definition: urlwrite.cc:124
is longer than or if then or only for unique occurrences of the complete pattern(false). The default is true. If a cell array of strings ar
Definition: strfind.cc:190
std::string url
Definition: urlwrite.cc:118
void get(const std::string &file, std::ostream &os)
Definition: url-transfer.h:227
octave::unwind_protect frame
Definition: graphics.cc:12190
bool is_ascii(void) const
Definition: url-transfer.h:205
std::ofstream ofile(filename.c_str(), std::ios::out|std::ios::binary)
void cwd(const std::string &path)
Definition: url-transfer.h:209
#define octave_stdout
Definition: pager.h:174
void http_action(const Array< std::string > &param, const std::string &action)
Definition: url-transfer.h:260
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
void del(const std::string &file)
Definition: url-transfer.h:211
otherwise an error message is printed The permission mask is a UNIX concept used when creating new objects on a file system such as files
Definition: file-io.cc:3038
static void delete_file(const std::string &file)
Definition: urlwrite.cc:56
url_transfer get_object(double val)
std::string method
Definition: urlwrite.cc:123
bool exists(void) const
Definition: file-stat.h:144
octave::sys::file_stat fs(filename)
args.length() nargin
Definition: file-io.cc:589
for i
Definition: data.cc:5264
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
std::string pwd(void)
Definition: url-transfer.h:254
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888