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