File size distribution: Difference between revisions

m
→‎{{header|REXX}}: increased numeric digits to handle extremely large disks, optimized code for reading of the workfile.
m (→‎{{header|REXX}}: optimized the reading of the workfile.)
m (→‎{{header|REXX}}: increased numeric digits to handle extremely large disks, optimized code for reading of the workfile.)
Line 414:
This REXX version works for Microsoft Windows using the   '''dir'''   subcommand;   extra code was added for
<br>older versions of Windows that used suffixes to express big numbers &nbsp; (the size of a file).
<lang rexx>/*REXX program displays a histogram of filesize distribution of a directory structure. (s)*/
numeric digits 2030 /*ensure enough decimal digits for a #. */
parse arg ds . /*obtain optional argument from the CL.*/
parse source . . path . /* " the path of this REXX program.*/
Line 421:
parse var fID fn '.' /* " just the pure filename of pgm.*/
sw=linesize() - 1; if sw<80 then sw=79 /* " terminal width (linesize) - 1.*/
dirOut= fn".OUT" /*construct filename for workfile output of DIR.*/
'DIR' ds '/s /-c /a-d >' dirOut /*do (DOS) DIR cmd for a data structure*/
call linein 0, 1 /*open output file, point to 1st record*/
maxL=0 /*maximum length of number of records. */
@.=00 /*stemmed array to hold record counts. */
g=0 /*number of good records found (so far)*/
$=0; do while lines(dirOut) \== 0 /*process data. */
_=linein(dirOUT); if left(_, 1)==' ' then iterate /*processNot datalegit? Skip. */
parse upper var _ . . sz . /*uppercase suffix*/
if \datatype(sz,'W') then do; #=left(sz, length(sz) - 1) /*SZ has a suffix?*/
if \datatype(#, 'N') then iterate /*Meat ¬ numeric? */
sfxsz= # * 1024 ** pos( right(sz, 1), 'KMGTPEZYXWVU') /*get the suffix. */1
end sz=#*1024**pos(sfx,'KMGTPEZYX')/1 /*compute true[↑] use valsuffix*/
end
$=$ + sz /*keep a running total for the filesize*/
if sz==0 then L=0 /*handle special case for an empty file*/