(*==================================================================== = Program Id: LISTDIRS.MOD = = Programmer: Peter M. Perchansky = = Copyright: Copyright (c) Peter M. Perchansky 1990 = = Purpose: List directories in current or specified dir. = = Date Written: 06-14-90 = = Memory Modle: Small = =------------------------------------------------------------------= = Version History = =------------------------------------------------------------------= = 06-14-90 PMP Date written. = ====================================================================*) (*# check( stack=>on, index=>on, range=>on, overflow=>on, nil_ptr=>on) *) (*# optimize( speed=>on, cse=>on, const=>on, peep_hole=>on, jump=>on, loop=>on, alias=>off, regass=>on, stk_frame=>on, i186=>on) *) MODULE ListDirs; (*------------- Procedures from JPI's TopSpeed Modula II -------------*) FROM IO IMPORT WrCharRep, WrLn, WrStr; FROM FIO IMPORT DirEntry, directory, hidden, FileAttr, GetDir; FROM FIO IMPORT GetDrive, ReadFirstEntry, ReadNextEntry; FROM Lib IMPORT ParamCount, ParamStr; FROM Str IMPORT Append, Length, Prepend; (*--------------------------------------------------------------------*) (*------------- Procedures from PMP's Library Modules ----------------*) FROM PMPStr IMPORT ItemsInString; (*--------------------------------------------------------------------*) TYPE PathStr = ARRAY [0..65] OF CHAR; VAR attribute : FileAttr; (* search attribute *) entry : DirEntry; (* directory entry info *) dir : PathStr; (* directory on command line *) BEGIN IF ParamCount () # 1 THEN GetDir (0, dir); Prepend (dir, ':'); Prepend (dir, CHR (GetDrive () + 64)); ELSE ParamStr (dir, 1) END; IF dir[Length (dir) - 1] # '\' THEN Append (dir, '\') END; WrLn; WrStr ("Directory: "); WrStr (dir); WrLn; WrLn; WrStr ("Subdirectories: "); WrLn; Append (dir, "*.*"); attribute := FileAttr {directory}; IF ReadFirstEntry (dir, attribute, entry) THEN REPEAT IF NOT (ItemsInString (entry.Name, ". ..")) AND (entry.attr = attribute) THEN WrCharRep (' ', 12); WrStr (entry.Name); WrLn; END UNTIL NOT ReadNextEntry (entry); END; END ListDirs.