(* 1---Module 02---1 *) PROCEDURE convertname(str : str20; VAR n : nameary; VAR t : typeary); VAR i, j : integer; BEGIN (* convertname *) FOR i := 1 TO namesize DO n[i] := ' '; FOR i := 1 TO typesize DO t[i] := ' '; IF (str = '') THEN str := '*.*'; IF (pos('.', str) = 0) THEN str := concat(str, '.'); IF NOT (pos('.', str)-1 > namesize) THEN FOR i := 1 TO pos('.', str)-1 DO n[i] := upcase(str[i]); IF NOT (length(copy(str, pos('.', str)+1, 20)) > typesize) THEN FOR i := pos('.', str)+1 TO length(str) DO t[i-pos('.', str)] := upcase(str[i]); FOR i := 1 TO namesize DO IF (n[i] = '*') THEN FOR j := i TO namesize DO n[j] := '?'; FOR i := 1 TO typesize DO IF (t[i] = '*') THEN FOR j := i TO typesize DO t[j] := '?'; END; (* convertname *) (* 1---------------1 *) FUNCTION samename(s : str20; fn : nameary; ft : typeary) : boolean; VAR n : nameary; t : typeary; i, j : integer; match : boolean; BEGIN (* samename *) convertname(s, n, t); match := true; FOR i := 1 TO namesize DO IF ((n[i] <> fn[i]) AND (n[i] <> '?')) THEN match := false; FOR i := 1 TO typesize DO IF ((t[i] <> ft[i]) AND (t[i] <> '?')) THEN match := false; samename := match; END; (* samename *) (* 1---------------1 *) PROCEDURE searchnextall(filename : str20; VAR error : integer); CONST sizepc_fcb = 32; VAR i, fcbspersector : integer; BEGIN (* searchnextall *) REPEAT error := founddir; { default } fcbspersector := (sectorsize DIV sizepc_fcb); IF ((diroffset MOD fcbspersector) = 0) THEN BEGIN diroffset := 0; nextsector(dirsector, dirtrack); readsector(dirsector, dirtrack, addr(dirbuffer)); dirsectorcount := dirsectorcount +1; END; IF (dirsectorcount < dirsecs) THEN BEGIN dos_fcb := ptr(addr(dirbuffer) + (diroffset * sizepc_fcb)); IF (dos_fcb^.name[1] IN [#0, #$f6, #$e5]) THEN error := mtdirectory; END ELSE error := eodirectory; diroffset := diroffset +1; UNTIL ((error = eodirectory) OR (error = mtdirectory) OR (samename(filename, dos_fcb^.name, dos_fcb^.extention))); IF (error = eodirectory) THEN BEGIN volumename := false; subdirname := false; END ELSE BEGIN volumename := (dos_fcb^.attribute AND $08) <> 0; subdirname := (dos_fcb^.attribute AND $10) <> 0; END END; (* searchnextall *) (* 1---------------1 *) PROCEDURE searchnext(fn : str20; VAR err : integer); BEGIN (* searchnext *) REPEAT searchnextall(fn, err); IF (dos_fcb^.name[1] = #0) THEN { "high water" mark } err := eodirectory; UNTIL ((err = eodirectory) OR (err = founddir)); END; (* searchnext *) (* 1---------------1 *) PROCEDURE searchfirstall(filename : str20; VAR error : integer); CONST sizepc_fcb = 32; VAR i : integer; BEGIN (* searchfirstall *) diroffset := 0; dirtrack := 0; dirsectorcount := -1; dirsector := firstdirsector - 1; searchnextall(filename, error); END; (* searchfirstall *) (* 1---------------1 *) PROCEDURE searchfirst(fn : str20; VAR err : integer); BEGIN (* searchfirst *) searchfirstall(fn, err); IF (err = mtdirectory) THEN searchnext(fn, err); END; (* searchfirst *) (* 1---------------1 *) PROCEDURE identifyms_dos; BEGIN (* identifyms_dos *) sectorsize := 512; recordspersector := sectorsize DIV 128; firstfatsector := 1; getfat; CASE fat[1] OF $ff: BEGIN identity := ds8spt; fatsize := 1; (* size of FAT in sectors (1 copy)*) dirsecs := 7; (* number of sectors in directory *) ntracks := 80; (* number of tracks on disk *) nsectors := 8; (* number of sectors per track *) secspercluster := 2; (* number of sectors per cluster *) singlesided := false; END; $fe: BEGIN identity := ss8spt; fatsize := 1; dirsecs := 4; ntracks := 40; nsectors := 8; secspercluster := 1; singlesided := true; END; $fd: BEGIN identity := ds9spt; fatsize := 2; dirsecs := 7; ntracks := 80; nsectors := 9; secspercluster := 2; singlesided := false; END; $fc: BEGIN identity := ss9spt; fatsize := 2; dirsecs := 4; ntracks := 40; nsectors := 9; secspercluster := 1; singlesided := true; END; ELSE BEGIN (* Try Another Sector Size *) { sectorsize := 256; firstfatsector := 2; { recordspersector := sectorsize DIV 128; { getfat; { CASE fat[1] OF { $f8: BEGIN { identity := b_20; (* Burroughs B-20 *) { fatsize := 2; dirsecs := 18; ntracks := 160; { nsectors := 16; secspercluster := 8; { singlesided := false; { END; { ELSE BEGIN } identity := unidentified; gotoxy(1, 23); write('Cannot Identify MS-DOS Disk, '); continue; END; (* else Case *) { END; (* Case *) { END; (* else Case *) } END; (* Case *) IF NOT (identity = unidentified) THEN BEGIN firstdirsector := fatsize * 2 + firstfatsector; firstdatasector := (firstdirsector + dirsecs) MOD nsectors; firstdatatrack := (firstdirsector + dirsecs) DIV nsectors; nclusters := (ntracks * nsectors DIV secspercluster) - (((fatsize * 2) + dirsecs + 1) DIV secspercluster); END; END; (* identifyms_dos *) (* 1---------------1 *) PROCEDURE restorefat; VAR s, t, i : integer; BEGIN (* restorefat *) clrscr; writeln; fatsize := 0; (* else null entry is garbage *) writeln('Copy auxiliary FAT into primary FAT. DANGEROUS'); writeln('9 sectors use 2, 8 sector use 1 (IBM standard)'); write('FAT Size in Sectors? (1,2,3) (others abort) =? '); readln(fatsize); IF fatsize IN [1..3] THEN BEGIN s := succ(fatsize); t := 0; FOR i := 0 TO pred(fatsize) DO BEGIN readsector(s, t, addr(fat) + (sectorsize * i)); nextsector(s, t); putfat; END; write(' Done, '); END ELSE write(' Aborted, '); continue; END; (* restorefat *) (* 1-End Module 02-1 *)