\ Display Directory 25jan85japSDIR is an alternate directory program which sorts the names and displays them, along with the actual length of the data in the file (instead of the amount of space used). It uses 731 bytes but is much faster than NDIR. Author: Robert B. Strand 2078 Linden Ave. Highland Park, IL 60035 2078 Linden Ave. Highland Park, IL 60035 (312) 433-2333 Modified and distributed by: John A. Peters (415) 239-5393 SF ( Screens 0, 2 & 4 ) F83 Disk Librarian NOTE: Very short files (3 sectors) show as 0 length. \ Display Directory - Load screen 05jan85rbs 08jan84jap 2 4 THRU DOS COLUMNS-VERT ( As opposed to COLUMNS-HORIZ ) EXIT \ Display Directory 05jan85rbs 08jan84japDOS DEFINITIONS VARIABLE DTOP VARIABLE DBOT : EXTNT# (S addr -- n ) 12 + C@ ; : .NAME&K (S addr -- ) DUP 1+ 8 2DUP TYPE ." ." + 3 TYPE DUP EXTNT# 128 * SWAP 15 + C@ + 8 / 4 .R ." k " ; defer COLUMN-TYPE : (COLUMNS-HORIZ) #OUT @ C/L > IF CR ELSE ." | " THEN ; : COLUMNS-HORIZ ['] (COLUMNS-HORIZ) IS COLUMN-TYPE ; : COLUMNS-VERT ['] CR IS COLUMN-TYPE ; : DISPLAY-NAMES DTOP @ DBOT @ DO I .NAME&K COLUMN-TYPE 32 +LOOP ; : NCOMPAR (S maddr\taddr -- maddr\f ) OVER 1+ SWAP 1+ 11 COMP ; \ Display Directory 05jan85rbs: NSEARCH (S taddr\faddr\laddr -- taddr\daddr\f ) 32 + 2DUP SWAP DO 2DROP I OVER NCOMPAR DUP 0<= IF LEAVE THEN 32 +LOOP 0= ; : OVERWRITE-ENTRY (S taddr\daddr -- ) 32 CMOVE ; : INSERT-ENTRY (S taddr\daddr\laddr -- ) OVER - 16 + OVER DUP 32 + ROT CMOVE> OVERWRITE-ENTRY ; : !NAME (S n -- ) 32 * PAD + DUP 10 + C@ 128 AND 0= IF DBOT @ DTOP @ NSEARCH IF OVER EXTNT# OVER EXTNT# > IF OVERWRITE-ENTRY ELSE 2DROP THEN ELSE DTOP @ DUP 32 + DUP 16 + SP@ U< IF DTOP ! INSERT-ENTRY ELSE 2DROP 2DROP THEN THEN ELSE DROP THEN ; \ Display Directory - SDIR 08jan84jap FORTH DEFINITIONS : SDIR (S -- ) [ DOS ] " ????????.????" FCB2 (!FCB) CR PAD SET-DMA PAD 128 + DUP DTOP ! DUP DBOT ! 16 BLANK FCB2 SEARCH0 DUP DOS-ERR? NOT IF BEGIN !NAME FCB2 SEARCH DUP DOS-ERR? UNTIL THEN DROP DISPLAY-NAMES ; : SD CR [ DOS ] COLUMNS-VERT SDIR ; : SDD CR [ DOS ] COLUMNS-HORIZ SDIR ; FORTH \ Display Directory 05jan85rbsThere are two ways to display a directory: the first is to scan the directory for valid entries and display the names as they are found, and the other is to capture all names, sort them, and then display them. The first method won't allow for the file size to be displayed, since it is derived by scanning the directory. The second method requires a goodly amount of free memory to store all the different file entries as they are accumulated and sorted. SDIR uses the latter method, so be sure that there is enough free space. Note that there are two quirks that I will leave as an exercize for anyone who needs to resolve them. The first is that I do not query DOS for the block size and disk capacity (derived fromthe disk parameter block), so that the end-of-file is all I display, rather than the allocated amount of disk. The second \ Display Directory 05jan85rbsis that if a file is greater than 512k (Heaven forbid!), the file size will be incorrect, because of the way CP/M handles extent numbers after the 32nd extent. Also, pplease note that I haven't checked this on any other DOS version than CP/M 2.2, and that CPM+ and the 16-bit CP/Ms will most likely have differences. \ Display Directory 05jan85rbs 08jan84japDTOP and DBOT are the addresses of the end and start of the sorting table, respectively EXTNT# picks up the extent number, given the address of the entry .NAME&K prints the name at the address supplied and calculates the size of the file by multiplying the number of extents by 128, adding the remaining record count, and dividing by 8 (the number of records per K) COLUMN-TYPE Defered to either horizontal or vertical. (COLUMNS-HORIZ) Make the four vertical columns. COLUMNS-HORIZ Installs the horizontal version into column-type.COLUMNS-VERT Installs the verticle version into column-type. DISPLAY-NAMES scans the sorting table and displays the names NCOMPAR compares the names of two entries and returns a three- value flag from the comparison \ Display Directory 05jan85rbsNSEARCH searches sequentially for the proper location to insert (or overwrite) an entry OVERWRITE-ENTRY puts the latest extent entry over that of a previously inserted entry INSERT-ENTRY adds a new entry at the target location by making a space for it first in memory !NAME installs a given entry in the table so long as it doesn't have the $SYS tag set (t2) and there is room in memory for it \ Display Directory - SDIR 05jan85rbs 08jan84jap SDIR sets up a search for all extents to be returned by DOS and stores them away using !NAME, which puts the entries in sorted order, using the highest extent for each entry, and excluding any $SYS entries. Then table is then displayed. PAD is used for a directory reading buffer, and DTOP and DBOT start above that and may extend up to the stack. The directory search terminates when no more entries are returned by SEARCH. SD Sorted Directory, verticle columns. SDD Sorted Directory, Horizontal columns.