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