Mercurial > hg > octave-terminal
changeset 10336:1603dfe72933
obsolete fstat, handle the functionality by stat
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 19 Feb 2010 06:58:13 +0100 |
parents | 9dd04a06410e |
children | 7c97da90fc8f |
files | scripts/deprecated/fstat.m scripts/deprecated/module.mk src/ChangeLog src/syscalls.cc |
diffstat | 4 files changed, 79 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/scripts/deprecated/fstat.m @@ -0,0 +1,35 @@ +## Copyright (C) 2010 VZLU Prague +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{info}, @var{err}, @var{msg}] = } fstat (fid) +## This function has been deprecated. Use stat instead. +## @end deftypefn + +## Deprecated in version 3.4 + +function [info, err, msg] = fstat (fid) + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "fstat is obsolete and will be removed from a future version of Octave, please use stat instead"); + endif + + [info, err, msg] = stat (fid); +endfunction
--- a/scripts/deprecated/module.mk +++ b/scripts/deprecated/module.mk @@ -6,6 +6,7 @@ deprecated/complement.m \ deprecated/create_set.m \ deprecated/dmult.m \ + deprecated/fstat.m \ deprecated/iscommand.m \ deprecated/israwcommand.m \ deprecated/isstr.m \
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-02-18 Jaroslav Hajek <highegg@gmail.com> + + * syscalls.cc (mk_stat_result): New helper function. + (Flstat): Call it here. + (Fstat): Also here. Handle also the fstat case here. + 2010-02-18 Thorsten Meyer <thorsten.meyier@gmx.de> * dirfns.cc (Fglob): Document globbing patterns, add test.
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -85,6 +85,27 @@ return m; } +static octave_value_list +mk_stat_result (const base_file_stat& fs) +{ + octave_value_list retval; + + if (fs) + { + retval(2) = std::string (); + retval(1) = 0; + retval(0) = octave_value (mk_stat_map (fs)); + } + else + { + retval(2) = fs.error (); + retval(1) = -1; + retval(0) = Matrix (); + } + + return retval; +} + DEFUNX ("dup2", Fdup2, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ @@ -719,43 +740,6 @@ return retval; } -DEFUNX ("fstat", Ffstat, args, , - "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} fstat (@var{fid})\n\ -Return information about the open file @var{fid}. See @code{stat}\n\ -for a description of the contents of @var{info}.\n\ -@end deftypefn") -{ - octave_value_list retval; - - if (args.length () == 1) - { - int fid = octave_stream_list::get_file_number (args(0)); - - if (! error_state) - { - file_fstat fs (fid); - - if (fs) - { - retval(2) = std::string (); - retval(1) = 0; - retval(0) = octave_value (mk_stat_map (fs)); - } - else - { - retval(2) = fs.error (); - retval(1) = -1; - retval(0) = Matrix (); - } - } - } - else - print_usage (); - - return retval; -} - DEFUNX ("lstat", Flstat, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\ @@ -772,18 +756,7 @@ { file_stat fs (fname, false); - if (fs) - { - retval(2) = std::string (); - retval(1) = 0; - retval(0) = mk_stat_map (fs); - } - else - { - retval(2) = fs.error (); - retval(1) = -1; - retval(0) = Matrix (); - } + retval = mk_stat_result (fs); } } else @@ -792,8 +765,6 @@ return retval; } - - DEFUNX ("mkfifo", Fmkfifo, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ @@ -999,23 +970,26 @@ if (args.length () == 1) { - std::string fname = args(0).string_value (); - - if (! error_state) + if (args(0).is_scalar_type ()) { - file_stat fs (fname); + int fid = octave_stream_list::get_file_number (args(0)); - if (fs) + if (! error_state) { - retval(2) = std::string (); - retval(1) = 0; - retval(0) = octave_value (mk_stat_map (fs)); + file_fstat fs (fid); + + retval = mk_stat_result (fs); } - else + } + else + { + std::string fname = args(0).string_value (); + + if (! error_state) { - retval(2) = fs.error (); - retval(1) = -1; - retval(0) = Matrix (); + file_stat fs (fname); + + retval = mk_stat_result (fs); } } }