home *** CD-ROM | disk | FTP | other *** search
- PWD: Print Working Directories on All Valid Drives
- in Turbo Pascal
-
- by
-
- Earl F. Glynn
- Overland Park, KS
- Compuserve 73257,3527
-
- (C) Copyright 1989, All Rights Reserved.
-
-
-
- File D e s c r i p t i o n
- ------------ ----------------------------------------------------------
- PWD.DOC This file.
- PWD.PAS Turbo Pascal source program.
- PWD.EXE Executable program.
- PWD.OUT Sample PWD output.
-
-
-
- Knowing all current working directories on all disk drives can
- shorten needed file specifications by using the path implied by the
- working directory. For example, if the default drive is C:, the
- working directory on drive D is
-
- D:\TP\GRAPHICS\EXAMPLES
-
- and the working directory on drive A is
-
- A:\NEW\EXAMPLES
-
- all the pascal files from the working directory of A can be copied
- to the working directory of D by entering the DOS command
-
- COPY A:*.PAS D:
-
- instead of the longer forms
-
- COPY A:\NEW\EXAMPLES\*.PAS D:\TP\GRAPHICS\EXAMPLES\*.*
- or
- COPY A:\NEW\EXAMPLES\*.PAS D:\TP\GRAPHICS\EXAMPLES
-
-
- The DOS prompt is often defined to be something like
-
- PROMPT $p$g (I prefer "PROMPT $p $t$h$h$h$_$g")
-
- to show the current default drive and directory. To find the working
- directory on drives other than the default drive, each drive must be
- selected and the directory displayed using either the CD command without
- parameters, or the DIR command. This can be a waste of time when
- all the working directories are correct but an interruption in work
- causes a lapse in (human) memory. On the other hand, assuming that
- certain working directories are defined, when in fact they are not, can
- lead to very serious results. The PWD command, written in Turbo
- Pascal 5.0, eliminates these problems.
-
- To execute the program, simply enter "PWD". The program has no
- parameters or options. PWD displays all working directories on all
- drives. While the program has been tested on several PC and MS DOS
- machines, it has only been tested with DOS 3.3. Sample output from PWD
- follows:
-
- Working Directories:
- A:\
- C:\TP\LIB
- D:\BBS
-
- My first choice in program name was SWD for "show working directory"
- to complement the existing DOS MD "make directory" and CD "change
- directory" commands. But since UNIX already has a command called PWD
- to "print working directory" I decided to use that name instead.
-
- PWD uses a number of undocumented DOS "features". Starting with
- the DOS List of Lists defined by DOS interrupt $21 function $52,
- information about the first "drive array" entry (BaseDA) and the number
- of drives (LastDrive) is found. Each "drive array" entry is a $51-byte
- (decimal 81) long RECORD. The first entry is the default or working
- directory of the drive in ASCIIZ format. But the "drive array" entry is
- not currently valid unless the "valid" field pointed to by the DPB
- (Disk Parameter Block) pointer is a zero. (Other very useful information
- is also defined in the Disk Parameter Block RECORD for the drive.)
- Each "drive array" entry is checked until the LastDrive is encountered,
- or the NextDPB pointer (DPB^.NextDPB^) is $FFFF.