annotate libinterp/corefcn/dirfns.cc @ 17281:bc924baa2c4e

doc: Add new @qcode macro for code samples which are quoted. Macro handles options ("on") or properties ("position") more elegantly than @code{"text"}. * doc/interpreter/macros.texi: Add new @qcode macro. * doc/interpreter/tips.txi: Add documentation about @qcode macro. * doc/interpreter/basics.txi, doc/interpreter/container.txi, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/func.txi, doc/interpreter/grammar.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/io.txi, doc/interpreter/matrix.txi, doc/interpreter/numbers.txi, doc/interpreter/oop.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/quad.txi, doc/interpreter/sparse.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m, scripts/general/dblquad.m, scripts/general/display.m, scripts/general/genvarname.m, scripts/general/idivide.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m, scripts/general/profexplore.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/triplequad.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m, scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/javaclasspath.m, scripts/java/usejava.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m, scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m, scripts/optimization/fminunc.m, scripts/optimization/fsolve.m, scripts/optimization/fzero.m, scripts/optimization/glpk.m, scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m, scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m, scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m, scripts/plot/plot.m, scripts/plot/print.m, scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m, scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m, scripts/polynomial/conv.m, scripts/polynomial/polyout.m, scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m, scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m, scripts/signal/periodogram.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/mean.m, scripts/statistics/base/moment.m, scripts/statistics/tests/cor_test.m, scripts/statistics/tests/kolmogorov_smirnov_test.m, scripts/statistics/tests/kolmogorov_smirnov_test_2.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m, scripts/statistics/tests/t_test_regression.m, scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m, scripts/statistics/tests/welch_test.m, scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m, scripts/strings/index.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/validatestring.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m, scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author Rik <rik@octave.org>
date Mon, 19 Aug 2013 20:46:38 -0700
parents e39f00a32dc7
children 0bf2fc8562c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
1 /*
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14022
diff changeset
3 Copyright (C) 1994-2012 John W. Eaton
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
4
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
6
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
10 option) any later version.
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
11
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
15 for more details.
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
16
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
19 <http://www.gnu.org/licenses/>.
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
20
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
21 */
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
22
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1158
diff changeset
24 #include <config.h>
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
25 #endif
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
26
1341
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
27 #include <cerrno>
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
28 #include <cstdio>
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
29 #include <cstddef>
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
30 #include <cstdlib>
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
31 #include <cstring>
e4e4131b1648 [project @ 1995-09-04 00:13:33 by jwe]
jwe
parents: 1328
diff changeset
32
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5640
diff changeset
33 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
34 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
35
1832
0c0d14cc90cd [project @ 1996-02-03 05:03:40 by jwe]
jwe
parents: 1804
diff changeset
36 #include <sys/types.h>
0c0d14cc90cd [project @ 1996-02-03 05:03:40 by jwe]
jwe
parents: 1804
diff changeset
37 #include <unistd.h>
0c0d14cc90cd [project @ 1996-02-03 05:03:40 by jwe]
jwe
parents: 1804
diff changeset
38
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
39 #include "file-ops.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
40 #include "file-stat.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
41 #include "glob-match.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
42 #include "oct-env.h"
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
43 #include "pathsearch.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
44 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
45
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents: 4928
diff changeset
46 #include "Cell.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
47 #include "defun.h"
1781
e090f89bf2f5 [project @ 1996-01-24 08:04:14 by jwe]
jwe
parents: 1773
diff changeset
48 #include "dir-ops.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
49 #include "dirfns.h"
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
50 #include "error.h"
1402
6550c74777b9 [project @ 1995-09-15 04:27:57 by jwe]
jwe
parents: 1401
diff changeset
51 #include "gripes.h"
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
52 #include "input.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
53 #include "load-path.h"
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
54 #include "octave-link.h"
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
55 #include "oct-obj.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
56 #include "pager.h"
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
57 #include "procstream.h"
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1341
diff changeset
58 #include "sysdep.h"
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
59 #include "toplev.h"
1449
df589c97e140 [project @ 1995-09-20 03:49:51 by jwe]
jwe
parents: 1402
diff changeset
60 #include "unwind-prot.h"
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
61 #include "utils.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
62 #include "variables.h"
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
63
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
64 // TRUE means we ask for confirmation before recursively removing a
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
65 // directory tree.
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
66 static bool Vconfirm_recursive_rmdir = true;
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
67
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6233
diff changeset
68 // The time we last time we changed directories.
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6233
diff changeset
69 octave_time Vlast_chdir_time = 0.0;
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6233
diff changeset
70
1328
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
71 static int
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
72 octave_change_to_directory (const std::string& newdir)
1328
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
73 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
74 std::string xdir = file_ops::tilde_expand (newdir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
75
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
76 int cd_ok = octave_env::chdir (xdir);
1328
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
77
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
78 if (cd_ok)
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
79 {
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6233
diff changeset
80 Vlast_chdir_time.stamp ();
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6233
diff changeset
81
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
82 // FIXME -- should these actions be handled as a list of functions
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
83 // to call so users can add their own chdir handlers?
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
84
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
85 load_path::update ();
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16094
diff changeset
86
16526
01541f7321f7 correctly track directory for cd ..
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
87 octave_link::change_directory (octave_env::get_current_directory ());
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
88 }
1328
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
89 else
10411
479cc8a0a846 use gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10348
diff changeset
90 error ("%s: %s", newdir.c_str (), gnulib::strerror (errno));
1328
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
91
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
92 return cd_ok;
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
93 }
ec2ab864e8eb [project @ 1995-08-22 22:32:34 by jwe]
jwe
parents: 1315
diff changeset
94
13912
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
95 DEFUN (cd, args, nargout,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
96 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11547
diff changeset
97 @deftypefn {Command} {} cd dir\n\
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11531
diff changeset
98 @deftypefnx {Command} {} chdir dir\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
99 Change the current working directory to @var{dir}. If @var{dir} is\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6482
diff changeset
100 omitted, the current directory is changed to the user's home\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
101 directory. For example,\n\
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
102 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
103 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
104 cd ~/octave\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
105 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
106 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
107 @noindent\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
108 changes the current working directory to @file{~/octave}. If the\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
109 directory does not exist, an error message is printed and the working\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
110 directory is not changed.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
111 @seealso{mkdir, rmdir, dir}\n\
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11531
diff changeset
112 @end deftypefn")
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
113 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
114 octave_value_list retval;
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
115
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
116 int argc = args.length () + 1;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
117
1965
01e3ed56c415 [project @ 1996-02-17 02:02:50 by jwe]
jwe
parents: 1957
diff changeset
118 string_vector argv = args.make_argv ("cd");
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
119
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
120 if (error_state)
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1750
diff changeset
121 return retval;
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
122
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
123 if (argc > 1)
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
124 {
5872
44f24cf66b95 [project @ 2006-06-30 18:19:20 by jwe]
jwe
parents: 5832
diff changeset
125 std::string dirname = argv[1];
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
126
1750
fd0d12493223 [project @ 1996-01-13 09:31:07 by jwe]
jwe
parents: 1742
diff changeset
127 if (dirname.length () > 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
128 && ! octave_change_to_directory (dirname))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
129 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
130 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
131 }
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
132 }
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
133 else
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
134 {
13912
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
135 // Behave like Unixy shells for "cd" by itself, but be Matlab
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
136 // compatible if doing "current_dir = cd".
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
137
13912
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
138 if (nargout == 0)
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
139 {
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
140 std::string home_dir = octave_env::get_home_directory ();
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
141
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
142 if (home_dir.empty () || ! octave_change_to_directory (home_dir))
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
143 return retval;
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
144 }
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
145 else
8d19194c4b1f cd: behave like unixy shells for "cd" alone, but be Matlab compatible if doing "current_dir = cd"
John W. Eaton <jwe@octave.org>
parents: 12681
diff changeset
146 retval = octave_value (octave_env::get_current_directory ());
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
147 }
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
148
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
149 return retval;
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
150 }
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
151
611
60f885cd0d87 [project @ 1994-08-14 20:53:44 by jwe]
jwe
parents: 549
diff changeset
152 DEFALIAS (chdir, cd);
60f885cd0d87 [project @ 1994-08-14 20:53:44 by jwe]
jwe
parents: 549
diff changeset
153
6482
7e958a1532c6 [project @ 2007-04-04 02:37:07 by jwe]
jwe
parents: 6323
diff changeset
154 DEFUN (pwd, , ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
155 "-*- texinfo -*-\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
156 @deftypefn {Built-in Function} {} pwd ()\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
157 Return the current working directory.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
158 @seealso{dir, ls}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
159 @end deftypefn")
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
160 {
10250
2d47356a7a1a use gnulib getcwd module
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
161 return octave_value (octave_env::get_current_directory ());
523
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
162 }
4a07f0083ab0 [project @ 1994-07-20 18:33:47 by jwe]
jwe
parents:
diff changeset
163
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
164 DEFUN (readdir, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
165 "-*- texinfo -*-\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
166 @deftypefn {Built-in Function} {[@var{files}, @var{err}, @var{msg}] =} readdir (@var{dir})\n\
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4494
diff changeset
167 Return names of the files in the directory @var{dir} as a cell array of\n\
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4494
diff changeset
168 strings. If an error occurs, return an empty cell array in @var{files}.\n\
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
169 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
170 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
171 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
172 system-dependent error message.\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11572
diff changeset
173 @seealso{ls, dir, glob}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
174 @end deftypefn")
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
175 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
176 octave_value_list retval;
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
177
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
178 retval(2) = std::string ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
179 retval(1) = -1.0;
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents: 4494
diff changeset
180 retval(0) = Cell ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
181
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
182 if (args.length () == 1)
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
183 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
184 std::string dirname = args(0).string_value ();
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
185
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
186 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
187 gripe_wrong_type_arg ("readdir", args(0));
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
188 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
189 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
190 dir_entry dir (dirname);
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
191
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
192 if (dir)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
193 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
194 string_vector dirlist = dir.read ();
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 13951
diff changeset
195 retval(1) = 0.0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
196 retval(0) = Cell (dirlist.sort ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
197 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
198 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
199 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
200 retval(2) = dir.error ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
201 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
202 }
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
203 }
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
204 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
205 print_usage ();
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
206
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
207 return retval;
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
208 }
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
209
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5765
diff changeset
210 // FIXME -- should maybe also allow second arg to specify
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
211 // mode? OTOH, that might cause trouble with compatibility later...
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
212
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
213 DEFUNX ("mkdir", Fmkdir, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
214 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
215 @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{dir})\n\
6192
5a53bf0f15b0 [project @ 2006-11-30 18:52:46 by jwe]
jwe
parents: 6187
diff changeset
216 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{parent}, @var{dir})\n\
8109
f3be63199134 Document mkdir()'s parent argument
weber@atlan
parents: 8008
diff changeset
217 Create a directory named @var{dir} in the directory @var{parent}.\n\
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
218 \n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
219 If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
220 character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
221 system-dependent error message, and @var{msgid} contains a unique\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
222 message identifier.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
223 @seealso{rmdir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
224 @end deftypefn")
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
225 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
226 octave_value_list retval;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
227
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
228 retval(2) = std::string ();
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
229 retval(1) = std::string ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
230 retval(0) = false;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
231
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
232 int nargin = args.length ();
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
233
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
234 std::string dirname;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
235
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
236 if (nargin == 2)
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
237 {
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
238 std::string parent = args(0).string_value ();
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
239 std::string dir = args(1).string_value ();
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
240
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
241 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
242 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
243 gripe_wrong_type_arg ("mkdir", args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
244 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
245 }
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
246 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
247 dirname = file_ops::concat (parent, dir);
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
248 }
6200
1ec9de3cd12c [project @ 2006-12-05 18:05:11 by jwe]
jwe
parents: 6192
diff changeset
249 else if (nargin == 1)
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
250 {
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
251 dirname = args(0).string_value ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
252
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
253 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
254 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
255 gripe_wrong_type_arg ("mkdir", args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
256 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
257 }
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
258 }
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
259
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
260 if (nargin == 1 || nargin == 2)
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
261 {
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
262 std::string msg;
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
263
7970
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
264 dirname = file_ops::tilde_expand (dirname);
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
265
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
266 file_stat fs (dirname);
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
267
7970
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
268 if (fs && fs.is_dir ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
269 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
270 // For compatibility with Matlab, we return true when the
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
271 // directory already exists.
7970
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
272
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
273 retval(2) = "mkdir";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
274 retval(1) = "directory exists";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
275 retval(0) = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
276 }
6187
2a8922007c12 [project @ 2006-11-29 01:59:59 by jwe]
jwe
parents: 6134
diff changeset
277 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
278 {
14741
0ab3dd0fad18 Backout changeset a543ed02e673: mkdir-p
John W. Eaton <jwe@octave.org>
parents: 14679
diff changeset
279 int status = octave_mkdir (dirname, 0777, msg);
7970
b6d4c644b4b6 Fmkdir: improve compatibility
John W. Eaton <jwe@octave.org>
parents: 7272
diff changeset
280
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
281 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
282 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
283 retval(2) = "mkdir";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
284 retval(1) = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
285 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
286 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
287 retval(0) = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
288 }
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
289 }
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
290 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
291 print_usage ();
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
292
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
293 return retval;
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
294 }
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
295
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
296 DEFUNX ("rmdir", Frmdir, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
297 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
298 @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir})\n\
12681
c09ed93d1a8b doc: Don't use @code{} within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents: 12668
diff changeset
299 @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir}, \"s\")\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
300 Remove the directory named @var{dir}.\n\
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
301 \n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
302 If successful, @var{status} is 1, with @var{msg} and @var{msgid} empty\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
303 character strings. Otherwise, @var{status} is 0, @var{msg} contains a\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
304 system-dependent error message, and @var{msgid} contains a unique\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
305 message identifier.\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
306 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
307 If the optional second parameter is supplied with value @qcode{\"s\"},\n\
6134
3010a2ecde0b [project @ 2006-11-02 15:29:28 by jwe]
jwe
parents: 6116
diff changeset
308 recursively remove all subdirectories as well.\n\
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
309 @seealso{mkdir, confirm_recursive_rmdir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
310 @end deftypefn")
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
311 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
312 octave_value_list retval;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
313
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
314 retval(2) = std::string ();
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
315 retval(1) = std::string ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
316 retval(0) = false;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
317
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
318 int nargin = args.length ();
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
319
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5444
diff changeset
320 if (nargin == 1 || nargin == 2)
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
321 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
322 std::string dirname = args(0).string_value ();
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
323
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
324 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
325 gripe_wrong_type_arg ("rmdir", args(0));
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
326 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
327 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
328 std::string fulldir = file_ops::tilde_expand (dirname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
329 int status = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
330 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
331
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
332 if (nargin == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
333 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
334 if (args(1).string_value () == "s")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
335 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
336 bool doit = true;
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
337
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
338 if (interactive && Vconfirm_recursive_rmdir)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
339 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
340 std::string prompt
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
341 = "remove entire contents of " + fulldir + "? ";
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
342
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
343 doit = octave_yes_or_no (prompt);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
344 }
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
345
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
346 if (doit)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
347 status = octave_recursive_rmdir (fulldir, msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
348 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
349 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
350 error ("rmdir: expecting second argument to be \"s\"");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
351 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
352 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
353 status = octave_rmdir (fulldir, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
354
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
355 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
356 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
357 retval(2) = "rmdir";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
358 retval(1) = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
359 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
360 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
361 retval(0) = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
362 }
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
363 }
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
364 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
365 print_usage ();
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
366
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
367 return retval;
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
368 }
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
369
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
370 DEFUNX ("link", Flink, args, ,
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
371 "-*- texinfo -*-\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
372 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} link (@var{old}, @var{new})\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
373 Create a new link (also known as a hard link) to an existing file.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
374 \n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
375 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
376 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
377 system-dependent error message.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
378 @seealso{symlink}\n\
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
379 @end deftypefn")
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
380 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
381 octave_value_list retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
382
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
383 retval(1) = std::string ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
384 retval(0) = -1.0;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
385
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
386 if (args.length () == 2)
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
387 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
388 std::string from = args(0).string_value ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
389
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
390 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
391 gripe_wrong_type_arg ("link", args(0));
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
392 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
393 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
394 std::string to = args(1).string_value ();
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
395
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
396 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
397 gripe_wrong_type_arg ("link", args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
398 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
399 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
400 std::string msg;
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
401
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
402 int status = octave_link (from, to, msg);
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
403
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
404 retval(0) = status;
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
405
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
406 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
407 retval(1) = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
408 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
409 }
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
410 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
411 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
412 print_usage ();
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
413
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
414 return retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
415 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
416
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
417 DEFUNX ("symlink", Fsymlink, args, ,
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
418 "-*- texinfo -*-\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
419 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} symlink (@var{old}, @var{new})\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
420 Create a symbolic link @var{new} which contains the string @var{old}.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
421 \n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
422 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
423 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
424 system-dependent error message.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
425 @seealso{link, readlink}\n\
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
426 @end deftypefn")
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
427 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
428 octave_value_list retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
429
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
430 retval(1) = std::string ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
431 retval(0) = -1.0;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
432
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
433 if (args.length () == 2)
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
434 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
435 std::string from = args(0).string_value ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
436
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
437 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
438 gripe_wrong_type_arg ("symlink", args(0));
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
439 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
440 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
441 std::string to = args(1).string_value ();
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
442
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
443 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
444 gripe_wrong_type_arg ("symlink", args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
445 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
446 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
447 std::string msg;
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
448
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
449 int status = octave_symlink (from, to, msg);
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
450
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
451 retval(0) = status;
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
452
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
453 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
454 retval(1) = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
455 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
456 }
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
457 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
458 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
459 print_usage ();
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
460
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
461 return retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
462 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
463
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
464 DEFUNX ("readlink", Freadlink, args, ,
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
465 "-*- texinfo -*-\n\
4169
d5667eaf8859 [project @ 2002-11-12 03:13:42 by jwe]
jwe
parents: 4051
diff changeset
466 @deftypefn {Built-in Function} {[@var{result}, @var{err}, @var{msg}] =} readlink (@var{symlink})\n\
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
467 Read the value of the symbolic link @var{symlink}.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
468 \n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
469 If successful, @var{result} contains the contents of the symbolic link\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
470 @var{symlink}, @var{err} is 0 and @var{msg} is an empty string.\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
471 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
472 system-dependent error message.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
473 @seealso{link, symlink}\n\
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
474 @end deftypefn")
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
475 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
476 octave_value_list retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
477
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
478 retval(2) = std::string ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
479 retval(1) = -1.0;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
480 retval(0) = std::string ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
481
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
482 if (args.length () == 1)
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
483 {
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
484 std::string symlink = args(0).string_value ();
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
485
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
486 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
487 gripe_wrong_type_arg ("readlink", args(0));
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
488 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
489 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
490 std::string result;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
491 std::string msg;
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
492
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
493 int status = octave_readlink (symlink, result, msg);
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
494
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
495 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
496 retval(2) = msg;
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 13951
diff changeset
497 retval(1) = status;
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 13951
diff changeset
498 retval(0) = result;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
499 }
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
500 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
501 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
502 print_usage ();
3710
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
503
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
504 return retval;
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
505 }
9a77deefb8c9 [project @ 2000-08-02 20:47:44 by jwe]
jwe
parents: 3690
diff changeset
506
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
507 DEFUNX ("rename", Frename, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
508 "-*- texinfo -*-\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
509 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} rename (@var{old}, @var{new})\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
510 Change the name of file @var{old} to @var{new}.\n\
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
511 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
512 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
513 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
514 system-dependent error message.\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
515 @seealso{ls, dir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
516 @end deftypefn")
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
517 {
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
518 octave_value_list retval;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
519
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
520 retval(1) = std::string ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
521 retval(0) = -1.0;
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
522
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
523 if (args.length () == 2)
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
524 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
525 std::string from = args(0).string_value ();
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
526
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
527 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
528 gripe_wrong_type_arg ("rename", args(0));
1402
6550c74777b9 [project @ 1995-09-15 04:27:57 by jwe]
jwe
parents: 1401
diff changeset
529 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
530 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
531 std::string to = args(1).string_value ();
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1690
diff changeset
532
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
533 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
534 gripe_wrong_type_arg ("rename", args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
535 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
536 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
537 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
538
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
539 int status = octave_rename (from, to, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
540
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
541 retval(0) = status;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2512
diff changeset
542
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
543 if (status < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
544 retval(1) = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
545 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
546 }
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
547 }
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
548 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
549 print_usage ();
1401
633199854158 [project @ 1995-09-15 04:15:27 by jwe]
jwe
parents: 1389
diff changeset
550
1389
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
551 return retval;
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
552 }
affbd42dd0c1 [project @ 1995-09-14 07:41:09 by jwe]
jwe
parents: 1380
diff changeset
553
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
554 DEFUN (glob, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
555 "-*- texinfo -*-\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
556 @deftypefn {Built-in Function} {} glob (@var{pattern})\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
557 Given an array of pattern strings (as a char array or a cell array) in\n\
5444
781c9e7dbb73 [project @ 2005-09-08 02:55:21 by jwe]
jwe
parents: 5307
diff changeset
558 @var{pattern}, return a cell array of file names that match any of\n\
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12211
diff changeset
559 them, or an empty cell array if no patterns match. The pattern strings are\n\
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10711
diff changeset
560 interpreted as filename globbing patterns (as they are used by Unix shells).\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
561 Within a pattern\n\
14366
b76f0740940e doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
562 \n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
563 @table @code\n\
16094
8899c785cc99 doc: Fix warnings associated with Texinfo 5.0 (bug #38392)
Rik <rik@octave.org>
parents: 15195
diff changeset
564 @item *\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
565 matches any string, including the null string,\n\
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 16526
diff changeset
566 \n\
16094
8899c785cc99 doc: Fix warnings associated with Texinfo 5.0 (bug #38392)
Rik <rik@octave.org>
parents: 15195
diff changeset
567 @item ?\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
568 matches any single character, and\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
569 \n\
10711
fbd7843974fa Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents: 10411
diff changeset
570 @item [@dots{}]\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
571 matches any of the enclosed characters.\n\
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
572 @end table\n\
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
573 \n\
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
574 Tilde expansion\n\
5444
781c9e7dbb73 [project @ 2005-09-08 02:55:21 by jwe]
jwe
parents: 5307
diff changeset
575 is performed on each of the patterns before looking for matching file\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
576 names. For example:\n\
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
577 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
578 @example\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
579 ls\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
580 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
581 file1 file2 file3 myfile1 myfile1b\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
582 glob (\"*file1\")\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
583 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
584 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
585 [1,1] = file1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
586 [2,1] = myfile1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
587 @}\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
588 glob (\"myfile?\")\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
589 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
590 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
591 [1,1] = myfile1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
592 @}\n\
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
593 glob (\"file[12]\")\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
594 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
595 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
596 [1,1] = file1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
597 [2,1] = file2\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
598 @}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
599 @end example\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11572
diff changeset
600 @seealso{ls, dir, readdir}\n\
5597
e0e48ea2a93c [project @ 2006-01-13 21:17:37 by jwe]
jwe
parents: 5476
diff changeset
601 @end deftypefn")
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
602 {
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
603 octave_value retval;
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
604
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
605 if (args.length () == 1)
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
606 {
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
607 string_vector pat = args(0).all_strings ();
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
608
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
609 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
610 gripe_wrong_type_arg ("glob", args(0));
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
611 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
612 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
613 glob_match pattern (file_ops::tilde_expand (pat));
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
614
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
615 retval = Cell (pattern.glob ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
616 }
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
617 }
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
618 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
619 print_usage ();
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
620
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
621 return retval;
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
622 }
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2442
diff changeset
623
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
624 /*
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
625 %!test
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
626 %! tmpdir = tmpnam;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
627 %! filename = {"file1", "file2", "file3", "myfile1", "myfile1b"};
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
628 %! if (mkdir (tmpdir))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
629 %! cwd = pwd;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
630 %! cd (tmpdir);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16892
diff changeset
631 %! if (strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir)))
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
632 %! a = 0;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
633 %! for n = 1:5
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
634 %! save (filename{n}, "a");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
635 %! endfor
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
636 %! else
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
637 %! rmdir (tmpdir);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
638 %! error ("Couldn't change to temporary dir");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
639 %! endif
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
640 %! else
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
641 %! error ("Couldn't create temporary directory");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
642 %! endif
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
643 %! result1 = glob ("*file1");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
644 %! result2 = glob ("myfile?");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
645 %! result3 = glob ("file[12]");
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
646 %! for n = 1:5
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
647 %! delete (filename{n});
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
648 %! endfor
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
649 %! cd (cwd);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
650 %! rmdir (tmpdir);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
651 %! assert (result1, {"file1"; "myfile1"});
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
652 %! assert (result2, {"myfile1"});
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14366
diff changeset
653 %! assert (result3, {"file1"; "file2"});
10335
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
654 */
9dd04a06410e document glob patterns
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10315
diff changeset
655
11531
f976dd63129c fnmatch: use DEFUNX until gnulib's fnmatch is C++ friendly
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
656 DEFUNX ("fnmatch", Ffnmatch, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
657 "-*- texinfo -*-\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
658 @deftypefn {Built-in Function} {} fnmatch (@var{pattern}, @var{string})\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
659 Return 1 or zero for each element of @var{string} that matches any of\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
660 the elements of the string array @var{pattern}, using the rules of\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
661 filename pattern matching. For example:\n\
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
662 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
663 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
664 @group\n\
6233
a299c8a6d96e [project @ 2007-01-09 04:31:18 by jwe]
jwe
parents: 6200
diff changeset
665 fnmatch (\"a*b\", @{\"ab\"; \"axyzb\"; \"xyzab\"@})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
666 @result{} [ 1; 1; 0 ]\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
667 @end group\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
668 @end example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3147
diff changeset
669 @end deftypefn")
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
670 {
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
671 octave_value retval;
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
672
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
673 if (args.length () == 2)
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
674 {
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
675 string_vector pat = args(0).all_strings ();
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
676 string_vector str = args(1).all_strings ();
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
677
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
678 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
679 gripe_wrong_type_arg ("fnmatch", args(0));
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
680 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
681 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
682 glob_match pattern (file_ops::tilde_expand (pat));
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
683
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
684 retval = pattern.match (str);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
685 }
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
686 }
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
687 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
688 print_usage ();
2496
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
689
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
690 return retval;
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
691 }
9823f8bfd1a5 [project @ 1996-11-11 03:17:10 by jwe]
jwe
parents: 2495
diff changeset
692
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
693 DEFUN (filesep, args, ,
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
694 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
695 @deftypefn {Built-in Function} {} filesep ()\n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
696 @deftypefnx {Built-in Function} {} filesep (\"all\")\n\
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
697 Return the system-dependent character used to separate directory names.\n\
8317
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
698 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
699 If @qcode{\"all\"} is given, the function returns all valid file separators\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
700 in the form of a string. The list of file separators is system-dependent.\n\
12668
e3dc23f7dd54 doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
701 It is @samp{/} (forward slash) under UNIX or @w{Mac OS X}, @samp{/} and\n\
e3dc23f7dd54 doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents: 12642
diff changeset
702 @samp{\\} (forward and backward slashes) under Windows.\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11572
diff changeset
703 @seealso{pathsep}\n\
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
704 @end deftypefn")
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
705 {
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
706 octave_value retval;
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
707
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
708 if (args.length () == 0)
8007
a2ab20ba78f7 make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 7970
diff changeset
709 retval = file_ops::dir_sep_str ();
8317
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
710 else if (args.length () == 1)
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
711 {
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
712 std::string s = args(0).string_value ();
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
713
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
714 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
715 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
716 if (s == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
717 retval = file_ops::dir_sep_chars ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
718 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
719 gripe_wrong_type_arg ("filesep", args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
720 }
8317
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
721 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
722 gripe_wrong_type_arg ("filesep", args(0));
8317
135c0e7d7802 Extend filesep functionality by allowing to return all valid file separators
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8109
diff changeset
723 }
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
724 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
725 print_usage ();
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
726
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
727 return retval;
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
728 }
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
729
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
730 DEFUN (pathsep, args, nargout,
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
731 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
732 @deftypefn {Built-in Function} {@var{val} =} pathsep ()\n\
9270
f9ac007bb926 fix typo in 9266:1d3b91166b9c
Jaroslav Hajek <highegg@gmail.com>
parents: 9266
diff changeset
733 @deftypefnx {Built-in Function} {@var{old_val} =} pathsep (@var{new_val})\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11572
diff changeset
734 Query or set the character used to separate directories in a path.\n\
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11572
diff changeset
735 @seealso{filesep}\n\
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
736 @end deftypefn")
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
737 {
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
738 octave_value retval;
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
739
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
740 int nargin = args.length ();
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
741
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
742 if (nargout > 0 || nargin == 0)
8008
4d13a7a2f6ab dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents: 8007
diff changeset
743 retval = dir_path::path_sep_str ();
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
744
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
745 if (nargin == 1)
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
746 {
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
747 std::string sval = args(0).string_value ();
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
748
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
749 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
750 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
751 switch (sval.length ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
752 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
753 case 1:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
754 dir_path::path_sep_char (sval[0]);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
755 break;
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
756
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
757 case 0:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
758 dir_path::path_sep_char ('\0');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
759 break;
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
760
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
761 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
762 error ("pathsep: argument must be a single character");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
763 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
764 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
765 }
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
766 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
767 error ("pathsep: argument must be a single character");
9266
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
768 }
1d3b91166b9c allow pathsep to be set
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
769 else if (nargin > 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
770 print_usage ();
5777
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
771
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
772 return retval;
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
773 }
246b1fc1e628 [project @ 2006-04-26 18:16:24 by jwe]
jwe
parents: 5775
diff changeset
774
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
775 DEFUN (confirm_recursive_rmdir, args, nargout,
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
776 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
777 @deftypefn {Built-in Function} {@var{val} =} confirm_recursive_rmdir ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
778 @deftypefnx {Built-in Function} {@var{old_val} =} confirm_recursive_rmdir (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13912
diff changeset
779 @deftypefnx {Built-in Function} {} confirm_recursive_rmdir (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
780 Query or set the internal variable that controls whether Octave\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
781 will ask for confirmation before recursively removing a directory tree.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13912
diff changeset
782 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
783 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
784 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
785 The original variable value is restored when exiting the function.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
786 @end deftypefn")
5640
426719471ac6 [project @ 2006-03-04 06:02:14 by jwe]
jwe
parents: 5639
diff changeset
787 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5777
diff changeset
788 return SET_INTERNAL_VARIABLE (confirm_recursive_rmdir);
4264
4e2d2516da22 [project @ 2003-01-03 05:30:34 by jwe]
jwe
parents: 4233
diff changeset
789 }