Mercurial > hg > octave-nkf
changeset 8317:135c0e7d7802
Extend filesep functionality by allowing to return all valid file separators
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Wed, 12 Nov 2008 12:31:56 +0000 |
parents | 830ad84d2654 |
children | cc29ef9a2d84 |
files | src/ChangeLog src/dirfns.cc |
diffstat | 2 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-11-12 Michael Goffioul <michael.goffioul@gmail.com> + + * dirfcn.cc (Ffilesep): Make it return all file separators when 'all' + is given as argument. + 2008-11-11 Jaroslav Hajek <highegg@gmail.com> * pt-assign.cc: Fix handling of empty cs-lists in assignment LHS.
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -637,7 +637,13 @@ DEFUN (filesep, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} filesep ()\n\ +@deftypefnx {Built-in Function} {} filesep ('all')\n\ Return the system-dependent character used to separate directory names.\n\ +\n\ +If 'all' is given, the function return all valid file separators in\n\ +the form of a string. The list of file separators is system-dependent.\n\ +It is / (forward slash) under UNIX or Mac OS X, / and \\ (forward and\n\ +backward slashes) under Windows.\n\ @seealso{pathsep, dir, ls}\n\ @end deftypefn") { @@ -645,6 +651,20 @@ if (args.length () == 0) retval = file_ops::dir_sep_str (); + else if (args.length () == 1) + { + std::string s = args(0).string_value (); + + if (! error_state) + { + if (s == "all") + retval = file_ops::dir_sep_chars (); + else + gripe_wrong_type_arg ("filesep", args(0)); + } + else + gripe_wrong_type_arg ("filesep", args(0)); + } else print_usage ();