523
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
523
|
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 2, or (at your option) any |
|
10 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, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
523
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
523
|
26 #endif |
|
27 |
1341
|
28 #include <cerrno> |
|
29 #include <cstdio> |
|
30 #include <cstddef> |
|
31 #include <cstdlib> |
|
32 #include <cstring> |
|
33 |
5765
|
34 #include <sstream> |
1728
|
35 #include <string> |
|
36 |
1832
|
37 #ifdef HAVE_UNISTD_H |
2442
|
38 #ifdef HAVE_SYS_TYPES_H |
1832
|
39 #include <sys/types.h> |
2442
|
40 #endif |
1832
|
41 #include <unistd.h> |
|
42 #endif |
|
43 |
2926
|
44 #include "file-ops.h" |
|
45 #include "file-stat.h" |
|
46 #include "glob-match.h" |
|
47 #include "oct-env.h" |
5777
|
48 #include "pathsearch.h" |
1755
|
49 #include "str-vec.h" |
|
50 |
5102
|
51 #include "Cell.h" |
1355
|
52 #include "defun.h" |
1781
|
53 #include "dir-ops.h" |
1355
|
54 #include "dirfns.h" |
|
55 #include "error.h" |
1402
|
56 #include "gripes.h" |
5640
|
57 #include "input.h" |
5832
|
58 #include "load-path.h" |
1750
|
59 #include "oct-obj.h" |
1355
|
60 #include "pager.h" |
|
61 #include "procstream.h" |
|
62 #include "sysdep.h" |
1750
|
63 #include "toplev.h" |
1449
|
64 #include "unwind-prot.h" |
523
|
65 #include "utils.h" |
1742
|
66 #include "variables.h" |
523
|
67 |
5640
|
68 // TRUE means we ask for confirmation before recursively removing a |
|
69 // directory tree. |
|
70 static bool Vconfirm_recursive_rmdir = true; |
|
71 |
1328
|
72 static int |
3523
|
73 octave_change_to_directory (const std::string& newdir) |
1328
|
74 { |
5979
|
75 int cd_ok = octave_env::chdir (file_ops::tilde_expand (newdir)); |
1328
|
76 |
|
77 if (cd_ok) |
5832
|
78 { |
|
79 // FIXME -- should this be handled as a list of functions |
|
80 // to call so users can add their own chdir handlers? |
|
81 |
|
82 load_path::update (); |
|
83 } |
1328
|
84 else |
3531
|
85 { |
|
86 using namespace std; |
|
87 |
|
88 error ("%s: %s", newdir.c_str (), strerror (errno)); |
|
89 } |
1328
|
90 |
|
91 return cd_ok; |
|
92 } |
|
93 |
4208
|
94 DEFCMD (cd, args, , |
3301
|
95 "-*- texinfo -*-\n\ |
|
96 @deffn {Command} cd dir\n\ |
|
97 @deffnx {Command} chdir dir\n\ |
|
98 Change the current working directory to @var{dir}. If @var{dir} is\n\ |
|
99 omitted, the current directory is changed to the users home\n\ |
|
100 directory. For example,\n\ |
523
|
101 \n\ |
3301
|
102 @example\n\ |
|
103 cd ~/octave\n\ |
|
104 @end example\n\ |
|
105 \n\ |
|
106 @noindent\n\ |
|
107 Changes the current working directory to @file{~/octave}. If the\n\ |
|
108 directory does not exist, an error message is printed and the working\n\ |
|
109 directory is not changed.\n\ |
5597
|
110 @seealso{mkdir, rmdir, dir}\n\ |
3301
|
111 @end deffn") |
523
|
112 { |
2086
|
113 octave_value_list retval; |
523
|
114 |
1755
|
115 int argc = args.length () + 1; |
|
116 |
1965
|
117 string_vector argv = args.make_argv ("cd"); |
1755
|
118 |
|
119 if (error_state) |
|
120 return retval; |
523
|
121 |
|
122 if (argc > 1) |
|
123 { |
5872
|
124 std::string dirname = argv[1]; |
523
|
125 |
1750
|
126 if (dirname.length () > 0 |
1755
|
127 && ! octave_change_to_directory (dirname)) |
523
|
128 { |
|
129 return retval; |
|
130 } |
|
131 } |
|
132 else |
|
133 { |
3523
|
134 std::string home_dir = octave_env::get_home_directory (); |
2926
|
135 |
|
136 if (home_dir.empty () || ! octave_change_to_directory (home_dir)) |
|
137 return retval; |
523
|
138 } |
|
139 |
|
140 return retval; |
|
141 } |
|
142 |
611
|
143 DEFALIAS (chdir, cd); |
|
144 |
1957
|
145 DEFUN (pwd, , nargout, |
3301
|
146 "-*- texinfo -*-\n\ |
|
147 @deftypefn {Built-in Function} {} pwd ()\n\ |
|
148 Return the current working directory.\n\ |
5597
|
149 @seealso{dir, ls}\n\ |
3301
|
150 @end deftypefn") |
523
|
151 { |
5979
|
152 return octave_value (octave_env::getcwd ()); |
523
|
153 } |
|
154 |
1957
|
155 DEFUN (readdir, args, , |
3301
|
156 "-*- texinfo -*-\n\ |
|
157 @deftypefn {Built-in Function} {[@var{files}, @var{err}, @var{msg}] =} readdir (@var{dir})\n\ |
4691
|
158 Return names of the files in the directory @var{dir} as a cell array of\n\ |
|
159 strings. If an error occurs, return an empty cell array in @var{files}.\n\ |
1389
|
160 \n\ |
3301
|
161 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
|
162 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ |
|
163 system-dependent error message.\n\ |
5597
|
164 @seealso{dir, glob}\n\ |
3301
|
165 @end deftypefn") |
1389
|
166 { |
2086
|
167 octave_value_list retval; |
1389
|
168 |
3523
|
169 retval(2) = std::string (); |
2669
|
170 retval(1) = -1.0; |
4691
|
171 retval(0) = Cell (); |
2669
|
172 |
1401
|
173 if (args.length () == 1) |
1389
|
174 { |
3523
|
175 std::string dirname = args(0).string_value (); |
1389
|
176 |
1401
|
177 if (error_state) |
1781
|
178 gripe_wrong_type_arg ("readdir", args(0)); |
1401
|
179 else |
|
180 { |
5872
|
181 dir_entry dir (dirname); |
1389
|
182 |
1401
|
183 if (dir) |
1389
|
184 { |
1781
|
185 string_vector dirlist = dir.read (); |
4691
|
186 retval(0) = Cell (dirlist.qsort ()); |
2669
|
187 retval(1) = 0.0; |
1401
|
188 } |
|
189 else |
|
190 { |
2669
|
191 retval(2) = dir.error (); |
1401
|
192 } |
1389
|
193 } |
|
194 } |
|
195 else |
5823
|
196 print_usage (); |
1389
|
197 |
1401
|
198 return retval; |
|
199 } |
|
200 |
5775
|
201 // FIXME -- should maybe also allow second arg to specify |
5476
|
202 // mode? OTOH, that might cause trouble with compatibility later... |
1401
|
203 |
5637
|
204 DEFCMD (mkdir, args, , |
3301
|
205 "-*- texinfo -*-\n\ |
5476
|
206 @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{dir})\n\ |
6192
|
207 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{parent}, @var{dir})\n\ |
3301
|
208 Create a directory named @var{dir}.\n\ |
1401
|
209 \n\ |
5476
|
210 If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\ |
|
211 character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\ |
|
212 system-dependent error message, and @var{msgid} contains a unique\n\ |
|
213 message identifier.\n\ |
5597
|
214 @seealso{rmdir}\n\ |
3301
|
215 @end deftypefn") |
1401
|
216 { |
2086
|
217 octave_value_list retval; |
1401
|
218 |
5476
|
219 retval(2) = std::string (); |
3523
|
220 retval(1) = std::string (); |
5476
|
221 retval(0) = false; |
1401
|
222 |
6187
|
223 int nargin = args.length (); |
|
224 |
|
225 std::string dirname; |
|
226 |
|
227 if (nargin == 2) |
1401
|
228 { |
6187
|
229 std::string parent = args(0).string_value (); |
|
230 std::string dir = args(1).string_value (); |
1401
|
231 |
|
232 if (error_state) |
|
233 { |
6187
|
234 gripe_wrong_type_arg ("mkdir", args(0)); |
|
235 return retval; |
|
236 } |
|
237 else |
|
238 dirname = parent + file_ops::dir_sep_char + dir; |
|
239 } |
|
240 else |
|
241 { |
|
242 dirname = args(0).string_value (); |
2669
|
243 |
6187
|
244 if (error_state) |
|
245 { |
|
246 gripe_wrong_type_arg ("mkdir", args(0)); |
|
247 return retval; |
|
248 } |
|
249 } |
|
250 |
|
251 if (nargin == 1 || nargin == 2) |
|
252 { |
|
253 std::string msg; |
|
254 |
|
255 int status = file_ops::mkdir (file_ops::tilde_expand (dirname), |
2926
|
256 0777, msg); |
1489
|
257 |
6187
|
258 if (status < 0) |
|
259 { |
|
260 retval(2) = "mkdir"; |
|
261 retval(1) = msg; |
1401
|
262 } |
6187
|
263 else |
|
264 retval(0) = true; |
1401
|
265 } |
|
266 else |
5823
|
267 print_usage (); |
1401
|
268 |
|
269 return retval; |
|
270 } |
|
271 |
5637
|
272 DEFCMD (rmdir, args, , |
3301
|
273 "-*- texinfo -*-\n\ |
5476
|
274 @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir})\n\ |
|
275 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir}, @code{\"s\"})\n\ |
3301
|
276 Remove the directory named @var{dir}.\n\ |
1401
|
277 \n\ |
5476
|
278 If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\ |
|
279 character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\ |
|
280 system-dependent error message, and @var{msgid} contains a unique\n\ |
|
281 message identifier.\n\ |
|
282 \n\ |
6134
|
283 If the optional second parameter is suplied with value @code{\"s\"},\n\ |
|
284 recursively remove all subdirectories as well.\n\ |
5640
|
285 @seealso{mkdir, confirm_recursive_rmdir}\n\ |
3301
|
286 @end deftypefn") |
1401
|
287 { |
2086
|
288 octave_value_list retval; |
1401
|
289 |
5476
|
290 retval(2) = std::string (); |
3523
|
291 retval(1) = std::string (); |
5476
|
292 retval(0) = false; |
1401
|
293 |
5476
|
294 int nargin = args.length (); |
|
295 |
|
296 if (nargin == 1 || nargin == 2) |
1401
|
297 { |
3523
|
298 std::string dirname = args(0).string_value (); |
1401
|
299 |
|
300 if (error_state) |
1402
|
301 gripe_wrong_type_arg ("rmdir", args(0)); |
1489
|
302 else |
1401
|
303 { |
5640
|
304 std::string fulldir = file_ops::tilde_expand (dirname); |
|
305 int status = -1; |
3523
|
306 std::string msg; |
2669
|
307 |
5639
|
308 if (nargin == 2) |
|
309 { |
|
310 if (args(1).string_value () == "s") |
5640
|
311 { |
|
312 bool doit = true; |
|
313 |
|
314 if (interactive && Vconfirm_recursive_rmdir) |
|
315 { |
|
316 std::string prompt |
|
317 = "remove entire contents of " + fulldir + "? "; |
|
318 |
|
319 doit = octave_yes_or_no (prompt); |
|
320 } |
|
321 |
|
322 if (doit) |
|
323 status = file_ops::recursive_rmdir (fulldir, msg); |
|
324 } |
5639
|
325 else |
|
326 error ("rmdir: expecting second argument to be \"s\""); |
|
327 } |
|
328 else |
5640
|
329 status = file_ops::rmdir (fulldir, msg); |
2669
|
330 |
|
331 if (status < 0) |
5476
|
332 { |
|
333 retval(2) = "rmdir"; |
|
334 retval(1) = msg; |
|
335 } |
|
336 else |
|
337 retval(0) = true; |
1401
|
338 } |
|
339 } |
1389
|
340 else |
5823
|
341 print_usage (); |
1401
|
342 |
|
343 return retval; |
|
344 } |
|
345 |
3710
|
346 DEFUN (link, args, , |
|
347 "-*- texinfo -*-\n\ |
|
348 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} link (@var{old}, @var{new})\n\ |
|
349 Create a new link (also known as a hard link) to an existing file.\n\ |
|
350 \n\ |
|
351 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
|
352 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ |
|
353 system-dependent error message.\n\ |
5597
|
354 @seealso{symlink}\n\ |
3710
|
355 @end deftypefn") |
|
356 { |
|
357 octave_value_list retval; |
|
358 |
|
359 retval(1) = std::string (); |
|
360 retval(0) = -1.0; |
|
361 |
|
362 if (args.length () == 2) |
|
363 { |
|
364 std::string from = args(0).string_value (); |
|
365 |
|
366 if (error_state) |
|
367 gripe_wrong_type_arg ("link", args(0)); |
|
368 else |
|
369 { |
|
370 std::string to = args(1).string_value (); |
|
371 |
|
372 if (error_state) |
|
373 gripe_wrong_type_arg ("link", args(1)); |
|
374 else |
|
375 { |
|
376 std::string msg; |
|
377 |
|
378 int status = file_ops::link (from, to, msg); |
|
379 |
4233
|
380 retval(0) = status; |
3710
|
381 |
|
382 if (status < 0) |
|
383 retval(1) = msg; |
|
384 } |
|
385 } |
|
386 } |
|
387 else |
5823
|
388 print_usage (); |
3710
|
389 |
|
390 return retval; |
|
391 } |
|
392 |
|
393 DEFUN (symlink, args, , |
|
394 "-*- texinfo -*-\n\ |
|
395 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} symlink (@var{old}, @var{new})\n\ |
|
396 Create a symbolic link @var{new} which contains the string @var{old}.\n\ |
|
397 \n\ |
|
398 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
|
399 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ |
|
400 system-dependent error message.\n\ |
5597
|
401 @seealso{link, readlink}\n\ |
3710
|
402 @end deftypefn") |
|
403 { |
|
404 octave_value_list retval; |
|
405 |
|
406 retval(1) = std::string (); |
|
407 retval(0) = -1.0; |
|
408 |
|
409 if (args.length () == 2) |
|
410 { |
|
411 std::string from = args(0).string_value (); |
|
412 |
|
413 if (error_state) |
|
414 gripe_wrong_type_arg ("symlink", args(0)); |
|
415 else |
|
416 { |
|
417 std::string to = args(1).string_value (); |
|
418 |
|
419 if (error_state) |
|
420 gripe_wrong_type_arg ("symlink", args(1)); |
|
421 else |
|
422 { |
|
423 std::string msg; |
|
424 |
|
425 int status = file_ops::symlink (from, to, msg); |
|
426 |
4233
|
427 retval(0) = status; |
3710
|
428 |
|
429 if (status < 0) |
|
430 retval(1) = msg; |
|
431 } |
|
432 } |
|
433 } |
|
434 else |
5823
|
435 print_usage (); |
3710
|
436 |
|
437 return retval; |
|
438 } |
|
439 |
|
440 DEFUN (readlink, args, , |
|
441 "-*- texinfo -*-\n\ |
4169
|
442 @deftypefn {Built-in Function} {[@var{result}, @var{err}, @var{msg}] =} readlink (@var{symlink})\n\ |
3710
|
443 Read the value of the symbolic link @var{symlink}.\n\ |
|
444 \n\ |
|
445 If successful, @var{result} contains the contents of the symbolic link\n\ |
|
446 @var{symlink}, @var{err} is 0 and @var{msg} is an empty string.\n\ |
|
447 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ |
|
448 system-dependent error message.\n\ |
5597
|
449 @seealso{link, symlink}\n\ |
3710
|
450 @end deftypefn") |
|
451 { |
|
452 octave_value_list retval; |
|
453 |
|
454 retval(2) = std::string (); |
|
455 retval(1) = -1.0; |
|
456 retval(0) = std::string (); |
|
457 |
|
458 if (args.length () == 1) |
|
459 { |
|
460 std::string symlink = args(0).string_value (); |
|
461 |
|
462 if (error_state) |
|
463 gripe_wrong_type_arg ("readlink", args(0)); |
|
464 else |
|
465 { |
|
466 std::string result; |
|
467 std::string msg; |
|
468 |
|
469 int status = file_ops::readlink (symlink, result, msg); |
|
470 |
|
471 retval(0) = result; |
|
472 |
4233
|
473 retval(1) = status; |
3710
|
474 |
|
475 if (status < 0) |
|
476 retval(2) = msg; |
|
477 } |
|
478 } |
|
479 else |
5823
|
480 print_usage (); |
3710
|
481 |
|
482 return retval; |
|
483 } |
|
484 |
1957
|
485 DEFUN (rename, args, , |
3301
|
486 "-*- texinfo -*-\n\ |
|
487 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} rename (@var{old}, @var{new})\n\ |
|
488 Change the name of file @var{old} to @var{new}.\n\ |
1401
|
489 \n\ |
3301
|
490 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
|
491 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ |
|
492 system-dependent error message.\n\ |
5597
|
493 @seealso{ls, dir}\n\ |
3301
|
494 @end deftypefn") |
1401
|
495 { |
2086
|
496 octave_value_list retval; |
1401
|
497 |
3523
|
498 retval(1) = std::string (); |
2669
|
499 retval(0) = -1.0; |
1401
|
500 |
|
501 if (args.length () == 2) |
|
502 { |
3523
|
503 std::string from = args(0).string_value (); |
1728
|
504 |
1401
|
505 if (error_state) |
1402
|
506 gripe_wrong_type_arg ("rename", args(0)); |
|
507 else |
1401
|
508 { |
3523
|
509 std::string to = args(1).string_value (); |
1728
|
510 |
1402
|
511 if (error_state) |
|
512 gripe_wrong_type_arg ("rename", args(1)); |
2669
|
513 else |
1402
|
514 { |
3523
|
515 std::string msg; |
2669
|
516 |
2926
|
517 int status = file_ops::rename (from, to, msg); |
2669
|
518 |
4233
|
519 retval(0) = status; |
2669
|
520 |
|
521 if (status < 0) |
|
522 retval(1) = msg; |
1402
|
523 } |
1401
|
524 } |
|
525 } |
|
526 else |
5823
|
527 print_usage (); |
1401
|
528 |
1389
|
529 return retval; |
|
530 } |
|
531 |
2495
|
532 DEFUN (glob, args, , |
3301
|
533 "-*- texinfo -*-\n\ |
|
534 @deftypefn {Built-in Function} {} glob (@var{pattern})\n\ |
5444
|
535 Given an array of strings (as a char array or a cell array) in\n\ |
|
536 @var{pattern}, return a cell array of file names that match any of\n\ |
|
537 them, or an empty cell array if no patterns match. Tilde expansion\n\ |
|
538 is performed on each of the patterns before looking for matching file\n\ |
|
539 names. For example,\n\ |
2495
|
540 \n\ |
3301
|
541 @example\n\ |
|
542 @group\n\ |
|
543 glob (\"/vm*\")\n\ |
|
544 @result{} \"/vmlinuz\"\n\ |
|
545 @end group\n\ |
|
546 @end example\n\ |
5597
|
547 @seealso{dir, ls, stat, readdir}\n\ |
|
548 @end deftypefn") |
2495
|
549 { |
|
550 octave_value retval; |
|
551 |
|
552 if (args.length () == 1) |
|
553 { |
|
554 string_vector pat = args(0).all_strings (); |
|
555 |
|
556 if (error_state) |
|
557 gripe_wrong_type_arg ("glob", args(0)); |
|
558 else |
|
559 { |
2926
|
560 glob_match pattern (file_ops::tilde_expand (pat)); |
2495
|
561 |
4691
|
562 retval = Cell (pattern.glob ()); |
2495
|
563 } |
|
564 } |
|
565 else |
5823
|
566 print_usage (); |
2495
|
567 |
|
568 return retval; |
|
569 } |
|
570 |
2496
|
571 DEFUN (fnmatch, args, , |
3301
|
572 "-*- texinfo -*-\n\ |
|
573 @deftypefn {Built-in Function} {} fnmatch (@var{pattern}, @var{string})\n\ |
|
574 Return 1 or zero for each element of @var{string} that matches any of\n\ |
|
575 the elements of the string array @var{pattern}, using the rules of\n\ |
|
576 filename pattern matching. For example,\n\ |
2496
|
577 \n\ |
3301
|
578 @example\n\ |
|
579 @group\n\ |
|
580 fnmatch (\"a*b\", [\"ab\"; \"axyzb\"; \"xyzab\"])\n\ |
|
581 @result{} [ 1; 1; 0 ]\n\ |
|
582 @end group\n\ |
|
583 @end example\n\ |
|
584 @end deftypefn") |
2496
|
585 { |
|
586 octave_value retval; |
|
587 |
|
588 if (args.length () == 2) |
|
589 { |
|
590 string_vector pat = args(0).all_strings (); |
|
591 string_vector str = args(1).all_strings (); |
|
592 |
|
593 if (error_state) |
|
594 gripe_wrong_type_arg ("fnmatch", args(0)); |
|
595 else |
|
596 { |
2926
|
597 glob_match pattern (file_ops::tilde_expand (pat)); |
2496
|
598 |
|
599 Array<bool> tmp = pattern.match (str); |
|
600 |
5275
|
601 octave_idx_type n = tmp.length (); |
2496
|
602 |
|
603 ColumnVector result (n); |
|
604 |
5275
|
605 for (octave_idx_type i = 0; i < n; i++) |
2496
|
606 result(i) = tmp(i); |
|
607 |
3418
|
608 retval = result; |
2496
|
609 } |
|
610 } |
|
611 else |
5823
|
612 print_usage (); |
2496
|
613 |
|
614 return retval; |
|
615 } |
|
616 |
5777
|
617 DEFUN (filesep, args, , |
5832
|
618 "-*- texinfo -*-\n\ |
|
619 @deftypefn {Built-in Function} {} filesep ()\n\ |
5777
|
620 Return the system-dependent character used to separate directory names.\n\ |
|
621 @seealso{pathsep, dir, ls}\n\ |
|
622 @end deftypefn") |
|
623 { |
|
624 octave_value retval; |
|
625 |
|
626 if (args.length () == 0) |
|
627 retval = file_ops::dir_sep_str; |
|
628 else |
5823
|
629 print_usage (); |
5777
|
630 |
|
631 return retval; |
|
632 } |
|
633 |
|
634 DEFUN (pathsep, args, , |
|
635 "-*- texinfo -*-\n\ |
|
636 @deftypefn {Built-in Function} {} pathsep ()\n\ |
|
637 Return the system-dependent character used to separate directories in\n\ |
|
638 a path.\n\ |
|
639 @seealso{filesep, dir, ls}\n\ |
|
640 @end deftypefn") |
|
641 { |
|
642 octave_value retval; |
|
643 |
|
644 if (args.length () == 0) |
|
645 retval = dir_path::path_sep_str; |
|
646 else |
5823
|
647 print_usage (); |
5777
|
648 |
|
649 return retval; |
|
650 } |
|
651 |
5794
|
652 DEFUN (confirm_recursive_rmdir, args, nargout, |
|
653 "-*- texinfo -*-\n\ |
|
654 @deftypefn {Built-in Function} {@var{val} =} confirm_recursive_rmdir ()\n\ |
|
655 @deftypefnx {Built-in Function} {@var{old_val} =} confirm_recursive_rmdir (@var{new_val})\n\ |
|
656 Query or set the internal variable that controls whether Octave\n\ |
|
657 will ask for confirmation before recursively removing a directory tree.\n\ |
|
658 @end deftypefn") |
5640
|
659 { |
5794
|
660 return SET_INTERNAL_VARIABLE (confirm_recursive_rmdir); |
4264
|
661 } |
|
662 |
523
|
663 /* |
|
664 ;;; Local Variables: *** |
|
665 ;;; mode: C++ *** |
|
666 ;;; End: *** |
|
667 */ |