Category : Modula II Source Code
Archive   : FLXCPY10.ZIP
Filename : DIRINFO.MOD

 
Output of file : DIRINFO.MOD contained in archive : FLXCPY10.ZIP
IMPLEMENTATION MODULE DirInfo;
(* Get file directory information. Base on the the GetNames routine in
the GetFiles module but returns more complete information. *)

FROM MSDOS IMPORT fcb,sfofc,snofc,fcb,sdafc,MSDOS,Registers,GetSegs,
fmffc,sdmfc,sdafc,Carry,OFFSET,SEGMENT;
FROM SYSTEM IMPORT ADR,ADDRESS,BYTE;

CONST
LwrMask = 20h; (* offset from lower case to upper case letters *)

(*********** From Definition Module ******************
FROM GetDate IMPORT DayOfWeek, TimeRec;
FROM MSDOS IMPORT Attributes, AttributesSet;

TYPE
FileName=ARRAY[0..13] OF CHAR;
DirEntry = RECORD
Name : FileName;
Attrib : AttributesSet;
fdate,
ftime : CARDINAL;
Size : LONGCARD;
END; (* DirEntry RECORD *)

VAR
SearchAttributes : AttributesSet;
********************************************)

PROCEDURE GetDirectory( Pattern : ARRAY OF CHAR;
VAR Entries : ARRAY OF DirEntry;
VAR Count : CARDINAL);
VAR i,j,k:INTEGER;
DevChar:CHAR;
WildCard:BOOLEAN;
Regs:Registers;
reply : CARDINAL;

(* return area for result *)

Buffer:RECORD
Reserved:ARRAY [0..20] OF BYTE;
Attr:BYTE;
Time,Date:CARDINAL;
Size : LONGCARD; (*not sure what these two words hold*)
Name:FileName;
END;

BEGIN (* GetDirectory *)
Count:=0; (* set up for directory search *)
GetSegs(Regs);
WITH Regs DO
(* set dma address *)
AH:=sdafc;
DX:=OFFSET(ADR(Buffer));
DS:=SEGMENT(ADR(Buffer));
MSDOS(Regs);
(* prepare search *)
AH:=fmffc;
CX:=SearchAttributes;
DX:=OFFSET(ADR(Pattern));
DS:=SEGMENT(ADR(Pattern));
MSDOS(Regs);
(* Now search for patterns *)

LOOP
IF Carry IN FLAGS THEN EXIT END;
IF Count>HIGH(Entries) THEN EXIT END;
(* Copy pertinent data to data array *)
Entries[Count].Name:=Buffer.Name;
Entries[Count].Size:=Buffer.Size;
Entries[Count].Attrib := Buffer.Attr;
(* fold file names to lower case *)
FOR i := 0 TO 13 DO
IF (Entries[Count].Name[i] >= 'A') AND (Entries[Count].Name[i] <= 'Z') THEN
Entries[Count].Name[i] := CHR(ORD(Entries[Count].Name[i]) + LwrMask);
END; (* IF *)
END; (* FOR i *)
(* Get the data and time into the time Rec *)
WITH Entries[Count] DO
ftime :=Buffer.Time;
fdate :=Buffer.Date;
END; (* WITH DT *)
INC(Count);
AH:=sdmfc;
MSDOS(Regs);
END;

(* Return DMA to 80h *)

AH:=sdafc;
DX:=80h;
MSDOS(Regs);
END;

END GetDirectory;

BEGIN (* DirInfo *)
SearchAttributes := AttributesSet{};
END DirInfo.


  3 Responses to “Category : Modula II Source Code
Archive   : FLXCPY10.ZIP
Filename : DIRINFO.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/