# HG changeset patch # User jwe # Date 1073845313 0 # Node ID dd8d08c41c0cbff223f8d9fe9a2a1f6ca298f418 # Parent 3387590ed11dca332f03707dfcdab402438ee60c [project @ 2004-01-11 18:20:51 by jwe] diff -r 3387590ed11d -r dd8d08c41c0c README.Windows --- a/README.Windows Sat Jan 10 22:49:19 2004 +0000 +++ b/README.Windows Sun Jan 11 18:21:53 2004 +0000 @@ -121,16 +121,26 @@ g. close gnuplot and start the Octave installation. 13. Get the Octave sources, either from a current snapshot - distribution or from CVS: + distribution or from CVS. + + You should check the web page http://www.octave.org/download.html + or look for the file RECOMMENDED-IS-N.NN.NN in the ftp download + directory to see what version is currently recommended (N.NN.NN + will be an actual version number, like 2.1.50). If more recent + versions may be available they should be considered experimental. + + The CVS sources are only recommended for people who want be + involved in Octave's development process and who don't mind + running into the occasional show-stopping bug. Snapshot: a. Download a copy of the current version of Octave from ftp://ftp.octave.org. You may use the command line ftp client in Cygwin or a web browser. You are looking for the - most recent version in the pub/octave/bleeding-edge + most recent recommended version in the pub/octave/bleeding-edge directory. At the time of this writing, it was - octave-2.1.46.tar.gz. Save this file to your Cygwin home + octave-2.1.50.tar.gz. Save this file to your Cygwin home directory. This directory will usually be called something like c:\cygwin\home\jwe from Windows (the precise location depends on where you chose to install Cygwin). @@ -144,15 +154,15 @@ b. Unpack the source files using the command: - tar zxf octave-2.1.46.tar.gz + tar zxf octave-2.1.50.tar.gz in the Cygwin shell. This command will create a subdirectory - called octave-2.1.46 in your home directory. + called octave-2.1.50 in your home directory. c. Change your current working directory to the top-level Octave source directory: - cd octave-2.1.46 + cd octave-2.1.50 then continue with step 14 below. @@ -241,4 +251,4 @@ University of Wisconsin-Madison Department of Chemical Engineering -Wed Apr 30 17:15:32 2003 +Sun Jan 11 12:19:47 2004 diff -r 3387590ed11d -r dd8d08c41c0c scripts/miscellaneous/dir.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/miscellaneous/dir.m Sun Jan 11 18:21:53 2004 +0000 @@ -0,0 +1,144 @@ +## Copyright (C) 2004 John W. Eaton +## +## 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 2, 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, write to the Free +## Software Foundation, 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} dir (@var{directory}) +## @deftypefnx {Function File} {[@var{list}] =} dir (@var{directory}) +## Display file listing for directory @var{directory}. If a return +## value is requested, return a structure array with the fields +## +## @example +## @group +## name +## bytes +## date +## isdir +## statinfo +## @end group +## @end example +## +## @noindent +## in which @code{statinfo} is the structure returned from @code{stat}. +## +## If @var{directory} is not a directory, return information about the +## named file. +## @var{filename}. +## @end deftypefn +## @seealso{stat} + +## Author: jwe + +## XXX FIXME XXX -- this is quite slow for large directories, so perhaps +## it should be converted to C++. + +function retval = dir (file) + + if (nargin == 1) + if (isstr (file)) + flst = glob (file); + nf = length (flst); + if (nf == 0) + if (nargout > 0) + ## XXX FIXME XXX -- need a way to create an empty (0x1) + ## structure array. + retval = []; + else + warning ("dir: nonexistent file \"%s\"", file); + endif + else + nt = 0; + len = zeros (nf, 1); + finfo = cell (nf, 1); + ## Collect results. + for i = nf:-1:1 + fn = flst{i}; + if (isstr (fn)) + [st, err, msg] = lstat (fn); + if (err < 0) + warning ("dir: nonexistent file \"%s\"", fn); + else + if (st.modestr(1) == "d") + lst = readdir (fn); + n = length (lst); + for j = n:-1:1 + tfn = lst{j}; + ## The lstat call seems to be the bottleneck for large + ## directories. + [st, err, msg] = lstat (strcat (fn, "/", tfn)); + if (err < 0) + warning ("dir: stat failed for %s (%s)", tfn, msg); + else + info(j).name = tfn; + ## Generating the pretty time string also takes a + ## significant amount of time for large directories. + info(j).date = strftime ("%d-%b-%Y %T", + localtime (st.mtime)); + info(j).bytes = st.size; + info(j).isdir = st.modestr(1) == "d"; + info(j).statinfo = st; + endif + endfor + else + info.name = fn; + info.date = strftime ("%d-%b-%Y %T", localtime (st.mtime)); + info.bytes = st.size; + info.isdir = st.modestr(1) == "d"; + info.statinfo = st; + endif + nt += (len(i) = length (info)); + finfo{i} = info; + endif + else + error ("dir: expecting filename argument to be a string"); + endif + endfor + ## Condense results to a single struct array. + ## XXX FIXME XXX -- need a way to create an empty (0x) struct + ## array in case the file is nonexistent. + if (nt == 0) + file_list = []; + else + off = 1; + for i = 1:nf + tlen = len(i); + file_list(off:off+tlen-1) = finfo{i}; + off += tlen; + endfor + endif + if (nargout > 0) + if (length (file_list) > 0) + retval = file_list; + else + retval = []; + endif + else + ## XXX FIXME XXX -- need a way to neatly list these in columns. + for i = 1:nt + printf (" %s\n", file_list(i).name); + endfor + endif + endif + else + error ("dir: expecting directory or filename to be a string"); + endif + else + usage ("dir (file)"); + endif + +endfunction