GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
url-transfer.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2018 John W. Eaton
4 Copyright (C) 2006-2018 Alexander Barth
5 Copyright (C) 2009 David Bateman
6 
7 This file is part of Octave.
8 
9 Octave is free software: you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <https://www.gnu.org/licenses/>.
22 
23 */
24 
25 // Author: Alexander Barth <abarth@marine.usf.edu>
26 // Author: jwe
27 
28 #if defined (HAVE_CONFIG_H)
29 # include "config.h"
30 #endif
31 
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 "unwind-prot.h"
41 #include "url-transfer.h"
42 
43 #if defined (HAVE_CURL)
44 # include <curl/curl.h>
45 # include <curl/curlver.h>
46 # include <curl/easy.h>
47 #endif
48 
49 namespace octave
50 {
51  void
53  {
54  sys::unlink (file);
55  }
56 
57  void
59  const std::string& target)
60  {
63 
64  if (! fs || ! fs.is_dir ())
65  {
66  std::string msg;
67  int status = sys::mkdir (directory, 0777, msg);
68 
69  if (status < 0)
70  {
71  ok = false;
72  errmsg = "__ftp_mget__: can not create directory '"
73  + target + sep + directory + "': " + msg;
74  return;
75  }
76  }
77 
78  cwd (directory);
79 
80  if (good ())
81  {
83 
84  frame.add_fcn (reset_path, this);
85 
86  string_vector sv = list ();
87 
88  for (octave_idx_type i = 0; i < sv.numel (); i++)
89  {
90  time_t ftime;
91  bool fisdir;
92  double fsize;
93 
94  get_fileinfo (sv(i), fsize, ftime, fisdir);
95 
96  if (fisdir)
97  mget_directory (sv(i), target + directory + sep);
98  else
99  {
100  std::string realfile = target + directory + sep + sv(i);
101 
102  std::ofstream ofile (realfile.c_str (),
103  std::ios::out | std::ios::binary);
104 
105  if (! ofile.is_open ())
106  {
107  ok = false;
108  errmsg = "__ftp_mget__: unable to open file";
109  break;
110  }
111 
112  unwind_protect_safe frame2;
113 
114  frame2.add_fcn (delete_file, realfile);
115 
116  get (sv(i), ofile);
117 
118  ofile.close ();
119 
120  if (good ())
121  frame2.discard ();
122  }
123 
124  if (! good ())
125  break;
126  }
127  }
128  }
129 
132  const std::string& directory)
133  {
134  string_vector file_list;
135 
136  std::string realdir
137  = (base.empty ()
139 
140  mkdir (directory);
141 
142  if (! good ())
143  return file_list;
144 
145  cwd (directory);
146 
147  if (good ())
148  {
150 
151  frame.add_fcn (reset_path, this);
152 
153  sys::dir_entry dirlist (realdir);
154 
155  if (dirlist)
156  {
157  string_vector files = dirlist.read ();
158 
159  for (octave_idx_type i = 0; i < files.numel (); i++)
160  {
161  std::string file = files (i);
162 
163  if (file == "." || file == "..")
164  continue;
165 
166  std::string realfile = realdir + sys::file_ops::dir_sep_str () + file;
167  sys::file_stat fs (realfile);
168 
169  if (! fs.exists ())
170  {
171  ok = false;
172  errmsg = "__ftp__mput: file '" + realfile
173  + "' does not exist";
174  break;
175  }
176 
177  if (fs.is_dir ())
178  {
179  file_list.append (mput_directory (realdir, file));
180 
181  if (! good ())
182  break;
183  }
184  else
185  {
186  // FIXME: Does ascii mode need to be flagged here?
187  std::ifstream ifile (realfile.c_str (), std::ios::in |
188  std::ios::binary);
189 
190  if (! ifile.is_open ())
191  {
192  ok = false;
193  errmsg = "__ftp_mput__: unable to open file '"
194  + realfile + "'";
195  break;
196  }
197 
198  put (file, ifile);
199 
200  ifile.close ();
201 
202  if (! good ())
203  break;
204 
205  file_list.append (realfile);
206  }
207  }
208  }
209  else
210  {
211  ok = false;
212  errmsg = "__ftp_mput__: can not read the directory '"
213  + realdir + "'";
214  }
215  }
216 
217  return file_list;
218  }
219 
220 #if defined (HAVE_CURL)
221 
222  static int
223  write_data (void *buffer, size_t size, size_t nmemb, void *streamp)
224  {
225  std::ostream& stream = *(static_cast<std::ostream *> (streamp));
226  stream.write (static_cast<const char *> (buffer), size*nmemb);
227  return (stream.fail () ? 0 : size * nmemb);
228  }
229 
230  static int
231  read_data (void *buffer, size_t size, size_t nmemb, void *streamp)
232  {
233  std::istream& stream = *(static_cast<std::istream *> (streamp));
234  stream.read (static_cast<char *> (buffer), size*nmemb);
235  if (stream.eof ())
236  return stream.gcount ();
237  else
238  return (stream.fail () ? 0 : size * nmemb);
239  }
240 
241  static size_t
242  throw_away (void *, size_t size, size_t nmemb, void *)
243  {
244  return static_cast<size_t>(size * nmemb);
245  }
246 
247  // I'd love to rewrite this as a private method of the url_transfer
248  // class, but you can't pass the va_list from the wrapper SETOPT to
249  // the curl_easy_setopt function.
250 #define SETOPT(option, parameter) \
251  do \
252  { \
253  CURLcode res = curl_easy_setopt (curl, option, parameter); \
254  if (res != CURLE_OK) \
255  { \
256  ok = false; \
257  errmsg = curl_easy_strerror (res); \
258  return; \
259  } \
260  } \
261  while (0)
262 
263  // Same as above but with a return value.
264 #define SETOPTR(option, parameter) \
265  do \
266  { \
267  CURLcode res = curl_easy_setopt (curl, option, parameter); \
268  if (res != CURLE_OK) \
269  { \
270  ok = false; \
271  errmsg = curl_easy_strerror (res); \
272  return retval; \
273  } \
274  } \
275  while (0)
276 
278  {
279  public:
280 
282  : base_url_transfer (), curl (curl_easy_init ()), errnum (), url (),
283  userpwd ()
284  {
285  if (curl)
286  valid = true;
287  else
288  errmsg = "can not create curl object";
289  }
290 
291  curl_transfer (const std::string& host, const std::string& user_arg,
292  const std::string& passwd, std::ostream& os)
293  : base_url_transfer (host, user_arg, passwd, os),
294  curl (curl_easy_init ()), errnum (), url (), userpwd ()
295  {
296  if (curl)
297  valid = true;
298  else
299  {
300  errmsg = "can not create curl object";
301  return;
302  }
303 
304  init (user_arg, passwd, std::cin, os);
305 
306  url = "ftp://" + host;
307  SETOPT (CURLOPT_URL, url.c_str ());
308 
309  // Set up the link, with no transfer.
310  perform ();
311  }
312 
313  curl_transfer (const std::string& url_str, std::ostream& os)
314  : base_url_transfer (url_str, os), curl (curl_easy_init ()), errnum (),
315  url (), userpwd ()
316  {
317  if (curl)
318  valid = true;
319  else
320  {
321  errmsg = "can not create curl object";
322  return;
323  }
324 
325  init ("", "", std::cin, os);
326 
327  std::string cainfo = sys::env::getenv ("CURLOPT_CAINFO");
328  if (! cainfo.empty ())
329  SETOPT (CURLOPT_CAINFO, cainfo.c_str ());
330 
331  std::string capath = sys::env::getenv ("CURLOPT_CAPATH");
332  if (! capath.empty ())
333  SETOPT (CURLOPT_CAPATH, capath.c_str ());
334 
335  SETOPT (CURLOPT_NOBODY, 0);
336 
337  // Restore the default HTTP request method to GET after setting
338  // NOBODY to true (in the init method) and back to false (above).
339  // This is needed for backward compatibility with versions of
340  // libcurl < 7.18.2.
341  SETOPT (CURLOPT_HTTPGET, 1);
342  }
343 
344  // No copying!
345 
346  curl_transfer (const curl_transfer&) = delete;
347 
348  curl_transfer& operator = (const curl_transfer&) = delete;
349 
351  {
352  if (curl)
353  curl_easy_cleanup (curl);
354  }
355 
356  void perform (void)
357  {
359 
360  errnum = curl_easy_perform (curl);
361 
362  if (errnum != CURLE_OK)
363  {
364  ok = false;
365  errmsg = curl_easy_strerror (errnum);
366  }
367 
369  }
370 
371  std::string lasterror (void) const
372  {
373  return std::string (curl_easy_strerror (errnum));
374  }
375 
376  std::ostream& set_ostream (std::ostream& os)
377  {
378  std::ostream& retval = *curr_ostream;
379  curr_ostream = &os;
380  SETOPTR (CURLOPT_WRITEDATA, static_cast<void *> (curr_ostream));
381  return retval;
382  }
383 
384  std::istream& set_istream (std::istream& is)
385  {
386  std::istream& retval = *curr_istream;
387  curr_istream = &is;
388  SETOPTR (CURLOPT_READDATA, static_cast<void *> (curr_istream));
389  return retval;
390  }
391 
392  void ascii (void)
393  {
394  ascii_mode = true;
395  SETOPT (CURLOPT_TRANSFERTEXT, 1);
396  }
397 
398  void binary (void)
399  {
400  ascii_mode = false;
401  SETOPT (CURLOPT_TRANSFERTEXT, 0);
402  }
403 
404  void cwd (const std::string& path)
405  {
406  ftp_file_or_dir_action (path, "cwd");
407  }
408 
409  void del (const std::string& file)
410  {
411  ftp_file_or_dir_action (file, "dele");
412  }
413 
414  void rmdir (const std::string& path)
415  {
416  ftp_file_or_dir_action (path, "rmd");
417  }
418 
419  void mkdir (const std::string& path)
420  {
421  ftp_file_or_dir_action (path, "mkd");
422  }
423 
424  void rename (const std::string& oldname, const std::string& newname)
425  {
426  struct curl_slist *slist = nullptr;
427 
429  frame.add_fcn (curl_slist_free_all, slist);
430 
431  std::string cmd = "rnfr " + oldname;
432  slist = curl_slist_append (slist, cmd.c_str ());
433  cmd = "rnto " + newname;
434  slist = curl_slist_append (slist, cmd.c_str ());
435  SETOPT (CURLOPT_POSTQUOTE, slist);
436 
437  perform ();
438  if (! good ())
439  return;
440 
441  SETOPT (CURLOPT_POSTQUOTE, 0);
442  }
443 
444  void put (const std::string& file, std::istream& is)
445  {
446  url = "ftp://" + host_or_url + '/' + file;
447  SETOPT (CURLOPT_URL, url.c_str ());
448  SETOPT (CURLOPT_UPLOAD, 1);
449  SETOPT (CURLOPT_NOBODY, 0);
450  std::istream& old_is = set_istream (is);
451 
452  perform ();
453  if (! good ())
454  return;
455 
456  set_istream (old_is);
457  SETOPT (CURLOPT_NOBODY, 1);
458  SETOPT (CURLOPT_UPLOAD, 0);
459  url = "ftp://" + host_or_url;
460  SETOPT (CURLOPT_URL, url.c_str ());
461  }
462 
463  void get (const std::string& file, std::ostream& os)
464  {
465  url = "ftp://" + host_or_url + '/' + file;
466  SETOPT (CURLOPT_URL, url.c_str ());
467  SETOPT (CURLOPT_NOBODY, 0);
468  std::ostream& old_os = set_ostream (os);
469 
470  perform ();
471  if (! good ())
472  return;
473 
474  set_ostream (old_os);
475  SETOPT (CURLOPT_NOBODY, 1);
476  url = "ftp://" + host_or_url;
477  SETOPT (CURLOPT_URL, url.c_str ());
478  }
479 
480  void dir (void)
481  {
482  url = "ftp://" + host_or_url + '/';
483  SETOPT (CURLOPT_URL, url.c_str ());
484  SETOPT (CURLOPT_NOBODY, 0);
485 
486  perform ();
487  if (! good ())
488  return;
489 
490  SETOPT (CURLOPT_NOBODY, 1);
491  url = "ftp://" + host_or_url;
492  SETOPT (CURLOPT_URL, url.c_str ());
493  }
494 
496  {
498 
499  std::ostringstream buf;
500  url = "ftp://" + host_or_url + '/';
501  SETOPTR (CURLOPT_WRITEDATA, static_cast<void *> (&buf));
502  SETOPTR (CURLOPT_URL, url.c_str ());
503  SETOPTR (CURLOPT_DIRLISTONLY, 1);
504  SETOPTR (CURLOPT_NOBODY, 0);
505 
506  perform ();
507  if (! good ())
508  return retval;
509 
510  SETOPTR (CURLOPT_NOBODY, 1);
511  url = "ftp://" + host_or_url;
512  SETOPTR (CURLOPT_WRITEDATA, static_cast<void *> (curr_ostream));
513  SETOPTR (CURLOPT_DIRLISTONLY, 0);
514  SETOPTR (CURLOPT_URL, url.c_str ());
515 
516  // Count number of directory entries
517  std::string str = buf.str ();
518  octave_idx_type n = 0;
519  size_t pos = 0;
520  while (true)
521  {
522  pos = str.find_first_of ('\n', pos);
523  if (pos == std::string::npos)
524  break;
525  pos++;
526  n++;
527  }
528  retval.resize (n);
529  pos = 0;
530  for (octave_idx_type i = 0; i < n; i++)
531  {
532  size_t newpos = str.find_first_of ('\n', pos);
533  if (newpos == std::string::npos)
534  break;
535 
536  retval(i) = str.substr(pos, newpos - pos);
537  pos = newpos + 1;
538  }
539 
540  return retval;
541  }
542 
543  void get_fileinfo (const std::string& filename, double& filesize,
544  time_t& filetime, bool& fileisdir)
545  {
546  std::string path = pwd ();
547 
548  url = "ftp://" + host_or_url + '/' + path + '/' + filename;
549  SETOPT (CURLOPT_URL, url.c_str ());
550  SETOPT (CURLOPT_FILETIME, 1);
551  SETOPT (CURLOPT_HEADERFUNCTION, throw_away);
552  SETOPT (CURLOPT_WRITEFUNCTION, throw_away);
553 
554  // FIXME
555  // The MDTM command fails for a directory on the servers I tested
556  // so this is a means of testing for directories. It also means
557  // I can't get the date of directories!
558 
559  perform ();
560  if (! good ())
561  {
562  fileisdir = true;
563  filetime = -1;
564  filesize = 0;
565 
566  return;
567  }
568 
569  fileisdir = false;
570  time_t ft;
571  curl_easy_getinfo (curl, CURLINFO_FILETIME, &ft);
572  filetime = ft;
573  double fs;
574  curl_easy_getinfo (curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fs);
575  filesize = fs;
576 
577  SETOPT (CURLOPT_WRITEFUNCTION, write_data);
578  SETOPT (CURLOPT_HEADERFUNCTION, 0);
579  SETOPT (CURLOPT_FILETIME, 0);
580  url = "ftp://" + host_or_url;
581  SETOPT (CURLOPT_URL, url.c_str ());
582 
583  // The MDTM command seems to reset the path to the root with the
584  // servers I tested with, so cd again into the correct path. Make
585  // the path absolute so that this will work even with servers that
586  // don't end up in the root after an MDTM command.
587  cwd ('/' + path);
588  }
589 
591  {
593 
594  struct curl_slist *slist = nullptr;
595 
597  frame.add_fcn (curl_slist_free_all, slist);
598 
599  slist = curl_slist_append (slist, "pwd");
600  SETOPTR (CURLOPT_POSTQUOTE, slist);
601  SETOPTR (CURLOPT_HEADERFUNCTION, write_data);
602 
603  std::ostringstream buf;
604  SETOPTR (CURLOPT_WRITEHEADER, static_cast<void *>(&buf));
605 
606  perform ();
607  if (! good ())
608  return retval;
609 
610  retval = buf.str ();
611 
612  // Can I assume that the path is alway in "" on the last line
613  size_t pos2 = retval.rfind ('"');
614  size_t pos1 = retval.rfind ('"', pos2 - 1);
615  retval = retval.substr (pos1 + 1, pos2 - pos1 - 1);
616 
617  SETOPTR (CURLOPT_HEADERFUNCTION, 0);
618  SETOPTR (CURLOPT_WRITEHEADER, 0);
619  SETOPTR (CURLOPT_POSTQUOTE, 0);
620 
621  return retval;
622  }
623 
625  {
626  url = host_or_url;
627 
628  std::string query_string = form_query_string (param);
629 
630  if (! query_string.empty ())
631  url += '?' + query_string;
632 
633  SETOPT (CURLOPT_URL, url.c_str ());
634 
635  perform ();
636  }
637 
639  {
640  SETOPT (CURLOPT_URL, host_or_url.c_str ());
641 
642  std::string query_string = form_query_string (param);
643 
644  SETOPT (CURLOPT_POSTFIELDS, query_string.c_str ());
645 
646  perform ();
647  }
648 
649  void http_action (const Array<std::string>& param, const std::string& action)
650  {
651  if (action.empty () || action == "get")
652  http_get (param);
653  else if (action == "post")
654  http_post (param);
655  else
656  {
657  ok = false;
658  errmsg = "curl_transfer: unknown http action";
659  }
660  }
661 
662  private:
663 
664  // Pointer to cURL object.
665  CURL *curl;
666 
667  // cURL error code.
668  CURLcode errnum;
669 
670  // The cURL library changed the curl_easy_setopt call to make an
671  // internal copy of string parameters in version 7.17.0. Prior
672  // versions only held a pointer to a string provided by the caller
673  // that must persist for the lifetime of the CURL handle.
674  //
675  // The associated API did not change, only the behavior of the library
676  // implementing the function call.
677  //
678  // To be compatible with any version of cURL, the caller must keep a
679  // copy of all string parameters associated with a CURL handle until
680  // the handle is released. The curl_handle::curl_handle_rep class
681  // contains the pointer to the CURL handle and so is the best
682  // candidate for storing the strings as well. (bug #36717)
685 
686  void init (const std::string& user, const std::string& passwd,
687  std::istream& is, std::ostream& os)
688  {
689  // No data transfer by default
690  SETOPT (CURLOPT_NOBODY, 1);
691 
692  // Set the username and password
693  userpwd = user;
694  if (! passwd.empty ())
695  userpwd += ':' + passwd;
696  if (! userpwd.empty ())
697  SETOPT (CURLOPT_USERPWD, userpwd.c_str ());
698 
699  // Define our callback to get called when there's data to be written.
700  SETOPT (CURLOPT_WRITEFUNCTION, write_data);
701 
702  // Set a pointer to our struct to pass to the callback.
703  SETOPT (CURLOPT_WRITEDATA, static_cast<void *> (&os));
704 
705  // Define our callback to get called when there's data to be read
706  SETOPT (CURLOPT_READFUNCTION, read_data);
707 
708  // Set a pointer to our struct to pass to the callback.
709  SETOPT (CURLOPT_READDATA, static_cast<void *> (&is));
710 
711  // Follow redirects.
712  SETOPT (CURLOPT_FOLLOWLOCATION, true);
713 
714  // Don't use EPSV since connecting to sites that don't support it
715  // will hang for some time (3 minutes?) before moving on to try PASV
716  // instead.
717  SETOPT (CURLOPT_FTP_USE_EPSV, false);
718 
719  SETOPT (CURLOPT_NOPROGRESS, true);
720  SETOPT (CURLOPT_FAILONERROR, true);
721 
722  SETOPT (CURLOPT_POSTQUOTE, 0);
723  SETOPT (CURLOPT_QUOTE, 0);
724  }
725 
727  {
728  std::ostringstream query;
729 
730  for (int i = 0; i < param.numel (); i += 2)
731  {
732  std::string name = param(i);
733  std::string text = param(i+1);
734 
735  // Encode strings.
736  char *enc_name = curl_easy_escape (curl, name.c_str (),
737  name.length ());
738  char *enc_text = curl_easy_escape (curl, text.c_str (),
739  text.length ());
740 
741  query << enc_name << '=' << enc_text;
742 
743  curl_free (enc_name);
744  curl_free (enc_text);
745 
746  if (i < param.numel ()-1)
747  query << '&';
748  }
749 
750  query.flush ();
751 
752  return query.str ();
753  }
754 
755  void ftp_file_or_dir_action (const std::string& file_or_dir,
756  const std::string& action)
757  {
758  struct curl_slist *slist = nullptr;
759 
761 
762  frame.add_fcn (curl_slist_free_all, slist);
763 
764  std::string cmd = action + ' ' + file_or_dir;
765 
766  slist = curl_slist_append (slist, cmd.c_str ());
767 
768  SETOPT (CURLOPT_POSTQUOTE, slist);
769 
770  perform ();
771 
772  if (! good ())
773  return;
774 
775  SETOPT (CURLOPT_POSTQUOTE, 0);
776  }
777  };
778 
779 #undef SETOPT
780 
781 #endif
782 
783 #if defined (HAVE_CURL)
784 # define REP_CLASS curl_transfer
785 #else
786 # define REP_CLASS base_url_transfer
787 #endif
788 
789  url_transfer::url_transfer (void) : rep (new REP_CLASS ())
790  { }
791 
793  const std::string& passwd, std::ostream& os)
794  : rep (new REP_CLASS (host, user, passwd, os))
795  { }
796 
798  : rep (new REP_CLASS (url, os))
799  { }
800 
801 #undef REP_CLASS
802 
803 }
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6704
void http_get(const Array< std::string > &param)
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
std::string lasterror(void) const
void ftp_file_or_dir_action(const std::string &file_or_dir, const std::string &action)
virtual void put(const std::string &, std::istream &)
Definition: url-transfer.h:123
int unlink(const std::string &name)
Definition: file-ops.cc:618
curl_transfer & operator=(const curl_transfer &)=delete
void del(const std::string &file)
std::string pwd(void)
std::ostream & set_ostream(std::ostream &os)
void get_fileinfo(const std::string &filename, double &filesize, time_t &filetime, bool &fileisdir)
std::istream & set_istream(std::istream &is)
void add_fcn(void(*fcn)(void))
void put(const std::string &file, std::istream &is)
static size_t throw_away(void *, size_t size, size_t nmemb, void *)
std::string filename
Definition: urlwrite.cc:121
void http_post(const Array< std::string > &param)
void http_action(const Array< std::string > &param, const std::string &action)
Definition: dir-ops.h:36
virtual string_vector list(void)
Definition: url-transfer.h:137
#define SETOPTR(option, parameter)
bool is_dir(void) const
Definition: file-stat.cc:57
std::string dir_sep_str(void)
Definition: file-ops.cc:233
static std::string getenv(const std::string &name)
Definition: oct-env.cc:235
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov.h:511
string_vector read(void)
Definition: dir-ops.cc:70
void rmdir(const std::string &path)
bool good(void) const
Definition: url-transfer.h:88
nd deftypefn *std::string name
Definition: sysdep.cc:647
static int write_data(void *buffer, size_t size, size_t nmemb, void *streamp)
#define REP_CLASS
curl_transfer(const std::string &url_str, std::ostream &os)
#define SETOPT(option, parameter)
std::string str
Definition: hash.cc:118
string_vector & append(const std::string &s)
Definition: str-vec.cc:107
octave_value retval
Definition: data.cc:6246
string_vector list(void)
virtual void get_fileinfo(const std::string &, double &, time_t &, bool &)
Definition: url-transfer.h:139
std::string form_query_string(const Array< std::string > &param)
curl_transfer(const std::string &host, const std::string &user_arg, const std::string &passwd, std::ostream &os)
Array< std::string > param
Definition: urlwrite.cc:124
static void reset_path(base_url_transfer *curl_xfer)
Definition: url-transfer.h:51
std::string url
Definition: urlwrite.cc:118
void mget_directory(const std::string &directory, const std::string &target)
Definition: url-transfer.cc:58
octave_value read(const Array< double > &size, octave_idx_type block_size, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt, octave_idx_type &count)
Definition: oct-stream.cc:6507
octave::unwind_protect frame
Definition: graphics.cc:12190
virtual void cwd(const std::string &)
Definition: url-transfer.h:112
int mkdir(const std::string &nm, mode_t md)
Definition: file-ops.cc:394
std::ofstream ofile(filename.c_str(), std::ios::out|std::ios::binary)
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
Definition: quit.h:217
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: url-transfer.cc:52
virtual void mkdir(const std::string &)
Definition: url-transfer.h:118
bool exists(void) const
Definition: file-stat.h:144
octave::sys::file_stat fs(filename)
for i
Definition: data.cc:5264
void mkdir(const std::string &path)
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
Definition: quit.h:213
void init(const std::string &user, const std::string &passwd, std::istream &is, std::ostream &os)
string_vector mput_directory(const std::string &base, const std::string &directory)
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
write the output to stdout if nargout is
Definition: load-save.cc:1612
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
void cwd(const std::string &path)
void rename(const std::string &oldname, const std::string &newname)
octave::stream os
Definition: file-io.cc:627
bool eof(void) const
Definition: oct-stream.cc:7194
std::ostream * curr_ostream
Definition: url-transfer.h:163
static int read_data(void *buffer, size_t size, size_t nmemb, void *streamp)
std::istream * curr_istream
Definition: url-transfer.h:162
OCTAVE_EXPORT octave_value_list directory
Definition: variables.cc:593