GNU Octave  4.0.0
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
dirfns.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <cerrno>
28 #include <cstdio>
29 #include <cstddef>
30 #include <cstdlib>
31 #include <cstring>
32 
33 #include <sstream>
34 #include <string>
35 
36 #include <sys/types.h>
37 #include <unistd.h>
38 
39 #include "file-ops.h"
40 #include "file-stat.h"
41 #include "glob-match.h"
42 #include "oct-env.h"
43 #include "pathsearch.h"
44 #include "str-vec.h"
45 
46 #include "Cell.h"
47 #include "defun.h"
48 #include "dir-ops.h"
49 #include "dirfns.h"
50 #include "error.h"
51 #include "gripes.h"
52 #include "input.h"
53 #include "load-path.h"
54 #include "octave-link.h"
55 #include "oct-obj.h"
56 #include "pager.h"
57 #include "procstream.h"
58 #include "sysdep.h"
59 #include "toplev.h"
60 #include "unwind-prot.h"
61 #include "utils.h"
62 #include "variables.h"
63 
64 // TRUE means we ask for confirmation before recursively removing a
65 // directory tree.
66 static bool Vconfirm_recursive_rmdir = true;
67 
68 // The time we last time we changed directories.
70 
71 static int
72 octave_change_to_directory (const std::string& newdir)
73 {
74  std::string xdir = file_ops::tilde_expand (newdir);
75 
76  int cd_ok = octave_env::chdir (xdir);
77 
78  if (cd_ok)
79  {
80  Vlast_chdir_time.stamp ();
81 
82  // FIXME: should these actions be handled as a list of functions
83  // to call so users can add their own chdir handlers?
84 
86 
88  }
89  else
90  error ("%s: %s", newdir.c_str (), gnulib::strerror (errno));
91 
92  return cd_ok;
93 }
94 
95 DEFUN (cd, args, nargout,
96  "-*- texinfo -*-\n\
97 @deftypefn {Command} {} cd @var{dir}\n\
98 @deftypefnx {Command} {} cd\n\
99 @deftypefnx {Built-in Function} {@var{old_dir} =} cd (@var{dir})\n\
100 @deftypefnx {Command} {} chdir @dots{}\n\
101 Change the current working directory to @var{dir}.\n\
102 \n\
103 If @var{dir} is omitted, the current directory is changed to the user's home\n\
104 directory (@qcode{\"~\"}).\n\
105 \n\
106 For example,\n\
107 \n\
108 @example\n\
109 cd ~/octave\n\
110 @end example\n\
111 \n\
112 @noindent\n\
113 changes the current working directory to @file{~/octave}. If the\n\
114 directory does not exist, an error message is printed and the working\n\
115 directory is not changed.\n\
116 \n\
117 @code{chdir} is an alias for @code{cd} and can be used in all of the same\n\
118 calling formats.\n\
119 \n\
120 Compatibility Note: When called with no arguments, @sc{matlab} prints the\n\
121 present working directory rather than changing to the user's home directory.\n\
122 @seealso{pwd, mkdir, rmdir, dir, ls}\n\
123 @end deftypefn")
124 {
125  octave_value_list retval;
126 
127  int argc = args.length () + 1;
128 
129  string_vector argv = args.make_argv ("cd");
130 
131  if (error_state)
132  return retval;
133 
134  if (nargout > 0)
136 
137  if (argc > 1)
138  {
139  std::string dirname = argv[1];
140 
141  if (dirname.length () > 0)
142  octave_change_to_directory (dirname);
143  }
144  else
145  {
146  std::string home_dir = octave_env::get_home_directory ();
147 
148  if (! home_dir.empty ())
149  octave_change_to_directory (home_dir);
150  }
151 
152  return retval;
153 }
154 
155 DEFALIAS (chdir, cd);
156 
157 DEFUN (pwd, , ,
158  "-*- texinfo -*-\n\
159 @deftypefn {Built-in Function} {} pwd ()\n\
160 @deftypefnx {Built-in Function} {@var{dir} =} pwd ()\n\
161 Return the current working directory.\n\
162 @seealso{cd, dir, ls, mkdir, rmdir}\n\
163 @end deftypefn")
164 {
166 }
167 
168 DEFUN (readdir, args, ,
169  "-*- texinfo -*-\n\
170 @deftypefn {Built-in Function} {@var{files} =} readdir (@var{dir})\n\
171 @deftypefnx {Built-in Function} {[@var{files}, @var{err}, @var{msg}] =} readdir (@var{dir})\n\
172 Return the names of files in the directory @var{dir} as a cell array of\n\
173 strings.\n\
174 \n\
175 If an error occurs, return an empty cell array in @var{files}.\n\
176 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
177 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
178 error message.\n\
179 @seealso{ls, dir, glob, what}\n\
180 @end deftypefn")
181 {
182  octave_value_list retval;
183 
184  retval(2) = std::string ();
185  retval(1) = -1.0;
186  retval(0) = Cell ();
187 
188  if (args.length () == 1)
189  {
190  std::string dirname = args(0).string_value ();
191 
192  if (error_state)
193  gripe_wrong_type_arg ("readdir", args(0));
194  else
195  {
196  dir_entry dir (dirname);
197 
198  if (dir)
199  {
200  string_vector dirlist = dir.read ();
201  retval(1) = 0.0;
202  retval(0) = Cell (dirlist.sort ());
203  }
204  else
205  {
206  retval(2) = dir.error ();
207  }
208  }
209  }
210  else
211  print_usage ();
212 
213  return retval;
214 }
215 
216 // FIXME: should maybe also allow second arg to specify mode?
217 // OTOH, that might cause trouble with compatibility later...
218 
219 DEFUNX ("mkdir", Fmkdir, args, ,
220  "-*- texinfo -*-\n\
221 @deftypefn {Built-in Function} {} mkdir @var{dir}\n\
222 @deftypefnx {Built-in Function} {} mkdir (@var{parent}, @var{dir})\n\
223 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@dots{})\n\
224 Create a directory named @var{dir} in the directory @var{parent}.\n\
225 \n\
226 If no @var{parent} directory is specified the present working directory is\n\
227 used.\n\
228 \n\
229 If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty\n\
230 character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a\n\
231 system-dependent error message, and @var{msgid} contains a unique message\n\
232 identifier.\n\
233 \n\
234 When creating a directory permissions will be set to\n\
235 @code{0777 - @var{umask}}.\n\
236 @seealso{rmdir, pwd, cd, umask}\n\
237 @end deftypefn")
238 {
239  octave_value_list retval;
240 
241  retval(2) = std::string ();
242  retval(1) = std::string ();
243  retval(0) = false;
244 
245  int nargin = args.length ();
246 
247  std::string dirname;
248 
249  if (nargin == 2)
250  {
251  std::string parent = args(0).string_value ();
252  std::string dir = args(1).string_value ();
253 
254  if (error_state)
255  {
256  gripe_wrong_type_arg ("mkdir", args(0));
257  return retval;
258  }
259  else
260  dirname = file_ops::concat (parent, dir);
261  }
262  else if (nargin == 1)
263  {
264  dirname = args(0).string_value ();
265 
266  if (error_state)
267  {
268  gripe_wrong_type_arg ("mkdir", args(0));
269  return retval;
270  }
271  }
272 
273  if (nargin == 1 || nargin == 2)
274  {
275  std::string msg;
276 
277  dirname = file_ops::tilde_expand (dirname);
278 
279  file_stat fs (dirname);
280 
281  if (fs && fs.is_dir ())
282  {
283  // For compatibility with Matlab, we return true when the
284  // directory already exists.
285 
286  retval(2) = "mkdir";
287  retval(1) = "directory exists";
288  retval(0) = true;
289  }
290  else
291  {
292  int status = octave_mkdir (dirname, 0777, msg);
293 
294  if (status < 0)
295  {
296  retval(2) = "mkdir";
297  retval(1) = msg;
298  }
299  else
300  retval(0) = true;
301  }
302  }
303  else
304  print_usage ();
305 
306  return retval;
307 }
308 
309 DEFUNX ("rmdir", Frmdir, args, ,
310  "-*- texinfo -*-\n\
311 @deftypefn {Built-in Function} {} rmdir @var{dir}\n\
312 @deftypefnx {Built-in Function} {} rmdir (@var{dir}, \"s\")\n\
313 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@dots{})\n\
314 Remove the directory named @var{dir}.\n\
315 \n\
316 If the optional second parameter is supplied with value @qcode{\"s\"},\n\
317 recursively remove all subdirectories as well.\n\
318 \n\
319 If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty\n\
320 character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a\n\
321 system-dependent error message, and @var{msgid} contains a unique message\n\
322 identifier.\n\
323 \n\
324 @seealso{mkdir, confirm_recursive_rmdir, pwd}\n\
325 @end deftypefn")
326 {
327  octave_value_list retval;
328 
329  retval(2) = std::string ();
330  retval(1) = std::string ();
331  retval(0) = false;
332 
333  int nargin = args.length ();
334 
335  if (nargin == 1 || nargin == 2)
336  {
337  std::string dirname = args(0).string_value ();
338 
339  if (error_state)
340  gripe_wrong_type_arg ("rmdir", args(0));
341  else
342  {
343  std::string fulldir = file_ops::tilde_expand (dirname);
344  int status = -1;
345  std::string msg;
346 
347  if (nargin == 2)
348  {
349  if (args(1).string_value () == "s")
350  {
351  bool doit = true;
352 
355  {
356  std::string prompt
357  = "remove entire contents of " + fulldir + "? ";
358 
359  doit = octave_yes_or_no (prompt);
360  }
361 
362  if (doit)
363  status = octave_recursive_rmdir (fulldir, msg);
364  }
365  else
366  error ("rmdir: expecting second argument to be \"s\"");
367  }
368  else
369  status = octave_rmdir (fulldir, msg);
370 
371  if (status < 0)
372  {
373  retval(2) = "rmdir";
374  retval(1) = msg;
375  }
376  else
377  retval(0) = true;
378  }
379  }
380  else
381  print_usage ();
382 
383  return retval;
384 }
385 
386 DEFUNX ("link", Flink, args, ,
387  "-*- texinfo -*-\n\
388 @deftypefn {Built-in Function} {} link @var{old} @var{new}\n\
389 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} link (@var{old}, @var{new})\n\
390 Create a new link (also known as a hard link) to an existing file.\n\
391 \n\
392 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
393 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
394 error message.\n\
395 @seealso{symlink, unlink, readlink, lstat}\n\
396 @end deftypefn")
397 {
398  octave_value_list retval;
399 
400  retval(1) = std::string ();
401  retval(0) = -1.0;
402 
403  if (args.length () == 2)
404  {
405  std::string from = args(0).string_value ();
406 
407  if (error_state)
408  gripe_wrong_type_arg ("link", args(0));
409  else
410  {
411  std::string to = args(1).string_value ();
412 
413  if (error_state)
414  gripe_wrong_type_arg ("link", args(1));
415  else
416  {
417  std::string msg;
418 
419  int status = octave_link (from, to, msg);
420 
421  if (status < 0)
422  retval(1) = msg;
423  retval(0) = status;
424  }
425  }
426  }
427  else
428  print_usage ();
429 
430  return retval;
431 }
432 
433 DEFUNX ("symlink", Fsymlink, args, ,
434  "-*- texinfo -*-\n\
435 @deftypefn {Built-in Function} {} symlink @var{old} @var{new}\n\
436 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} symlink (@var{old}, @var{new})\n\
437 Create a symbolic link @var{new} which contains the string @var{old}.\n\
438 \n\
439 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
440 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
441 error message.\n\
442 @seealso{link, unlink, readlink, lstat}\n\
443 @end deftypefn")
444 {
445  octave_value_list retval;
446 
447  retval(1) = std::string ();
448  retval(0) = -1.0;
449 
450  if (args.length () == 2)
451  {
452  std::string from = args(0).string_value ();
453 
454  if (error_state)
455  gripe_wrong_type_arg ("symlink", args(0));
456  else
457  {
458  std::string to = args(1).string_value ();
459 
460  if (error_state)
461  gripe_wrong_type_arg ("symlink", args(1));
462  else
463  {
464  std::string msg;
465 
466  int status = octave_symlink (from, to, msg);
467 
468  if (status < 0)
469  retval(1) = msg;
470  retval(0) = status;
471  }
472  }
473  }
474  else
475  print_usage ();
476 
477  return retval;
478 }
479 
480 DEFUNX ("readlink", Freadlink, args, ,
481  "-*- texinfo -*-\n\
482 @deftypefn {Built-in Function} {} readlink @var{symlink}\n\
483 @deftypefnx {Built-in Function} {[@var{result}, @var{err}, @var{msg}] =} readlink (@var{symlink})\n\
484 Read the value of the symbolic link @var{symlink}.\n\
485 \n\
486 If successful, @var{result} contains the contents of the symbolic link\n\
487 @var{symlink}, @var{err} is 0, and @var{msg} is an empty string.\n\
488 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
489 error message.\n\
490 @seealso{lstat, symlink, link, unlink, delete}\n\
491 @end deftypefn")
492 {
493  octave_value_list retval;
494 
495  retval(2) = std::string ();
496  retval(1) = -1.0;
497  retval(0) = std::string ();
498 
499  if (args.length () == 1)
500  {
501  std::string symlink = args(0).string_value ();
502 
503  if (error_state)
504  gripe_wrong_type_arg ("readlink", args(0));
505  else
506  {
507  std::string result;
508  std::string msg;
509 
510  int status = octave_readlink (symlink, result, msg);
511 
512  if (status < 0)
513  retval(2) = msg;
514  retval(1) = status;
515  retval(0) = result;
516  }
517  }
518  else
519  print_usage ();
520 
521  return retval;
522 }
523 
524 DEFUNX ("rename", Frename, args, ,
525  "-*- texinfo -*-\n\
526 @deftypefn {Built-in Function} {} rename @var{old} @var{new}\n\
527 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} rename (@var{old}, @var{new})\n\
528 Change the name of file @var{old} to @var{new}.\n\
529 \n\
530 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
531 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
532 error message.\n\
533 @seealso{movefile, copyfile, ls, dir}\n\
534 @end deftypefn")
535 {
536  octave_value_list retval;
537 
538  retval(1) = std::string ();
539  retval(0) = -1.0;
540 
541  if (args.length () == 2)
542  {
543  std::string from = args(0).string_value ();
544 
545  if (error_state)
546  gripe_wrong_type_arg ("rename", args(0));
547  else
548  {
549  std::string to = args(1).string_value ();
550 
551  if (error_state)
552  gripe_wrong_type_arg ("rename", args(1));
553  else
554  {
555  std::string msg;
556 
557  int status = octave_rename (from, to, msg);
558 
559  if (status < 0)
560  retval(1) = msg;
561  retval(0) = status;
562  }
563  }
564  }
565  else
566  print_usage ();
567 
568  return retval;
569 }
570 
571 DEFUN (glob, args, ,
572  "-*- texinfo -*-\n\
573 @deftypefn {Built-in Function} {} glob (@var{pattern})\n\
574 Given an array of pattern strings (as a char array or a cell array) in\n\
575 @var{pattern}, return a cell array of file names that match any of\n\
576 them, or an empty cell array if no patterns match.\n\
577 \n\
578 The pattern strings are interpreted as filename globbing patterns (as they\n\
579 are used by Unix shells).\n\
580 \n\
581 Within a pattern\n\
582 \n\
583 @table @code\n\
584 @item *\n\
585 matches any string, including the null string,\n\
586 \n\
587 @item ?\n\
588 matches any single character, and\n\
589 \n\
590 @item [@dots{}]\n\
591 matches any of the enclosed characters.\n\
592 @end table\n\
593 \n\
594 Tilde expansion is performed on each of the patterns before looking for\n\
595 matching file names. For example:\n\
596 \n\
597 @example\n\
598 ls\n\
599  @result{}\n\
600  file1 file2 file3 myfile1 myfile1b\n\
601 glob (\"*file1\")\n\
602  @result{}\n\
603  @{\n\
604  [1,1] = file1\n\
605  [2,1] = myfile1\n\
606  @}\n\
607 glob (\"myfile?\")\n\
608  @result{}\n\
609  @{\n\
610  [1,1] = myfile1\n\
611  @}\n\
612 glob (\"file[12]\")\n\
613  @result{}\n\
614  @{\n\
615  [1,1] = file1\n\
616  [2,1] = file2\n\
617  @}\n\
618 @end example\n\
619 @seealso{ls, dir, readdir, what}\n\
620 @end deftypefn")
621 {
622  octave_value retval;
623 
624  if (args.length () == 1)
625  {
626  string_vector pat = args(0).all_strings ();
627 
628  if (error_state)
629  gripe_wrong_type_arg ("glob", args(0));
630  else
631  {
632  glob_match pattern (file_ops::tilde_expand (pat));
633 
634  retval = Cell (pattern.glob ());
635  }
636  }
637  else
638  print_usage ();
639 
640  return retval;
641 }
642 
643 /*
644 %!test
645 %! tmpdir = tempname;
646 %! filename = {"file1", "file2", "file3", "myfile1", "myfile1b"};
647 %! if (mkdir (tmpdir))
648 %! cwd = pwd;
649 %! cd (tmpdir);
650 %! if (strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir)))
651 %! a = 0;
652 %! for n = 1:5
653 %! save (filename{n}, "a");
654 %! endfor
655 %! else
656 %! rmdir (tmpdir);
657 %! error ("Couldn't change to temporary dir");
658 %! endif
659 %! else
660 %! error ("Couldn't create temporary directory");
661 %! endif
662 %! result1 = glob ("*file1");
663 %! result2 = glob ("myfile?");
664 %! result3 = glob ("file[12]");
665 %! for n = 1:5
666 %! delete (filename{n});
667 %! endfor
668 %! cd (cwd);
669 %! rmdir (tmpdir);
670 %! assert (result1, {"file1"; "myfile1"});
671 %! assert (result2, {"myfile1"});
672 %! assert (result3, {"file1"; "file2"});
673 */
674 
675 DEFUN (__fnmatch__, args, ,
676  "-*- texinfo -*-\n\
677 @deftypefn {Built-in Function} {} fnmatch (@var{pattern}, @var{string})\n\
678 Return true or false for each element of @var{string} that matches any of\n\
679 the elements of the string array @var{pattern}, using the rules of\n\
680 \n\
681 filename pattern matching. For example:\n\
682 \n\
683 @example\n\
684 @group\n\
685 fnmatch (\"a*b\", @{\"ab\"; \"axyzb\"; \"xyzab\"@})\n\
686  @result{} [ 1; 1; 0 ]\n\
687 @end group\n\
688 @end example\n\
689 @seealso{glob, regexp}\n\
690 @end deftypefn")
691 {
692  octave_value retval;
693 
694  if (args.length () == 2)
695  {
696  string_vector pat = args(0).all_strings ();
697  string_vector str = args(1).all_strings ();
698 
699  if (error_state)
700  gripe_wrong_type_arg ("fnmatch", args(0));
701  else
702  {
703  glob_match pattern (file_ops::tilde_expand (pat));
704 
705  retval = pattern.match (str);
706  }
707  }
708  else
709  print_usage ();
710 
711  return retval;
712 }
713 
714 DEFUN (filesep, args, ,
715  "-*- texinfo -*-\n\
716 @deftypefn {Built-in Function} {} filesep ()\n\
717 @deftypefnx {Built-in Function} {} filesep (\"all\")\n\
718 Return the system-dependent character used to separate directory names.\n\
719 \n\
720 If @qcode{\"all\"} is given, the function returns all valid file separators\n\
721 in the form of a string. The list of file separators is system-dependent.\n\
722 It is @samp{/} (forward slash) under UNIX or @w{Mac OS X}, @samp{/} and\n\
723 @samp{\\} (forward and backward slashes) under Windows.\n\
724 @seealso{pathsep}\n\
725 @end deftypefn")
726 {
727  octave_value retval;
728 
729  if (args.length () == 0)
730  retval = file_ops::dir_sep_str ();
731  else if (args.length () == 1)
732  {
733  std::string s = args(0).string_value ();
734 
735  if (! error_state)
736  {
737  if (s == "all")
738  retval = file_ops::dir_sep_chars ();
739  else
740  gripe_wrong_type_arg ("filesep", args(0));
741  }
742  else
743  gripe_wrong_type_arg ("filesep", args(0));
744  }
745  else
746  print_usage ();
747 
748  return retval;
749 }
750 
751 DEFUN (pathsep, args, nargout,
752  "-*- texinfo -*-\n\
753 @deftypefn {Built-in Function} {@var{val} =} pathsep ()\n\
754 @deftypefnx {Built-in Function} {@var{old_val} =} pathsep (@var{new_val})\n\
755 Query or set the character used to separate directories in a path.\n\
756 @seealso{filesep}\n\
757 @end deftypefn")
758 {
759  octave_value retval;
760 
761  int nargin = args.length ();
762 
763  if (nargout > 0 || nargin == 0)
764  retval = dir_path::path_sep_str ();
765 
766  if (nargin == 1)
767  {
768  std::string sval = args(0).string_value ();
769 
770  if (! error_state)
771  {
772  switch (sval.length ())
773  {
774  case 1:
775  dir_path::path_sep_char (sval[0]);
776  break;
777 
778  case 0:
780  break;
781 
782  default:
783  error ("pathsep: argument must be a single character");
784  break;
785  }
786  }
787  else
788  error ("pathsep: argument must be a single character");
789  }
790  else if (nargin > 1)
791  print_usage ();
792 
793  return retval;
794 }
795 
796 DEFUN (confirm_recursive_rmdir, args, nargout,
797  "-*- texinfo -*-\n\
798 @deftypefn {Built-in Function} {@var{val} =} confirm_recursive_rmdir ()\n\
799 @deftypefnx {Built-in Function} {@var{old_val} =} confirm_recursive_rmdir (@var{new_val})\n\
800 @deftypefnx {Built-in Function} {} confirm_recursive_rmdir (@var{new_val}, \"local\")\n\
801 Query or set the internal variable that controls whether Octave\n\
802 will ask for confirmation before recursively removing a directory tree.\n\
803 \n\
804 When called from inside a function with the @qcode{\"local\"} option, the\n\
805 variable is changed locally for the function and any subroutines it calls.\n\
806 The original variable value is restored when exiting the function.\n\
807 @seealso{rmdir}\n\
808 @end deftypefn")
809 {
810  return SET_INTERNAL_VARIABLE (confirm_recursive_rmdir);
811 }
OCTAVE_EXPORT octave_value_list Freadlink(const octave_value_list &args, int)
Definition: dirfns.cc:491
int octave_rename(const std::string &from, const std::string &to)
Definition: file-ops.cc:517
Definition: Cell.h:35
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
Definition: gripes.cc:135
string_vector read(void)
Definition: dir-ops.cc:70
static std::string path_sep_str(void)
Definition: pathsearch.h:95
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
static int octave_change_to_directory(const std::string &newdir)
Definition: dirfns.cc:72
octave_idx_type length(void) const
Definition: oct-obj.h:89
OCTAVE_EXPORT octave_value_list Frmdir(const octave_value_list &args, int)
Definition: dirfns.cc:325
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
void error(const char *fmt,...)
Definition: error.cc:476
bool forced_interactive
Definition: input.cc:107
int octave_symlink(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:463
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:120
int octave_link(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:440
void stamp(void)
Definition: oct-time.cc:84
OCTAVE_EXPORT octave_value_list Flink(const octave_value_list &args, int)
Definition: dirfns.cc:396
int octave_mkdir(const std::string &nm, mode_t md)
Definition: file-ops.cc:392
static bool Vconfirm_recursive_rmdir
Definition: dirfns.cc:66
static std::string tilde_expand(const std::string &)
Definition: file-ops.cc:286
#define DEFALIAS(alias, name)
Definition: defun.h:63
static std::string concat(const std::string &, const std::string &)
Definition: file-ops.cc:360
bool interactive
Definition: input.cc:103
static char path_sep_char(void)
Definition: pathsearch.h:85
static std::string get_current_directory(void)
Definition: oct-env.cc:139
static bool chdir(const std::string &newdir)
Definition: oct-env.cc:259
OCTAVE_EXPORT octave_value_list Fsymlink(const octave_value_list &args, int)
Definition: dirfns.cc:443
int error_state
Definition: error.cc:101
#define DEFUNX(name, fname, args_name, nargout_name, doc)
Definition: defun.h:52
bool match(const std::string &str) const
Definition: glob-match.cc:33
string_vector & sort(bool make_uniq=false)
Definition: str-vec.cc:107
octave_idx_type length(void) const
Definition: ov.cc:1525
int octave_readlink(const std::string &path, std::string &result)
Definition: file-ops.cc:486
std::string error(void) const
Definition: dir-ops.h:71
static std::string dir_sep_chars(void)
Definition: file-ops.h:68
bool octave_yes_or_no(const std::string &prompt)
Definition: input.cc:798
octave_time Vlast_chdir_time
Definition: dirfns.cc:69
static void update(void)
Definition: load-path.h:85
int octave_rmdir(const std::string &name)
Definition: file-ops.cc:540
OCTAVE_EXPORT octave_value_list Fmkdir(const octave_value_list &args, int)
Definition: dirfns.cc:237
bool is_dir(void) const
Definition: file-stat.cc:56
Definition: dir-ops.h:30
OCTAVE_EXPORT octave_value_list Frename(const octave_value_list &args, int)
Definition: dirfns.cc:534
static std::string dir_sep_str(void)
Definition: file-ops.h:63
int octave_recursive_rmdir(const std::string &name)
Definition: file-ops.cc:564
string_vector glob(void) const
Definition: glob-match.cc:39
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
static std::string get_home_directory(void)
Definition: oct-env.cc:146