home *** CD-ROM | disk | FTP | other *** search
- {$P1024}
- Program List_ARChives;
- {
- The basis for this program and the 'GetList' procedure
- was an outgrowth of the DIRECTRY.PAS from Turbo Tutor by Borland
- and List_Files_for_Archive by Joseph W. Kalinski Ver 1.1 7/12/86
-
- Parameters are: LARC [d:] [/p]
-
- [d:] = drive to search
- [/p] = pause list every 23 lines
- }
- Type
-
- Char12arr = array [ 1..12 ] of Char;
- String13 = string[ 13 ];
- String05 = String[ 05 ];
- String08 = String[ 08 ];
-
- RegisterSet = Record Case Integer Of
- 1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
- 2: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
- End;
-
- DTA_Record = Record Case Integer of
- 1: (DTA_Buffer : Array [ 1..43 ] of Byte);
- 2: (DOS_Area : Array [ 0..20 ] of Byte;
- Attr : Byte;
- Time : Integer;
- Date : Integer;
- Size : Array [ 1..4 ] of Byte;
- Name : Array [ 1..13 ] of Char);
- End;
-
- ARC_Record = Record
- FileName : String[13];
- FileDate : String[08];
- FileTime : String[05];
- FileSize : Real;
- End;
-
- Var
-
- Regs : RegisterSet;
- DTA : DTA_Record;
- Mask : Char12arr;
- NamR : String13;
- I : Integer;
-
- SubList : Array[1..250] of String[63];
- ArcList : Array[1..250] of Arc_Record;
-
- SaveDir : String[63];
-
- Files,
- k,o,p : Integer;
- Pause : Boolean;
- Ans : Char;
- Tot_Files : Integer;
- Tot_Bytes : Real;
- Tot_Floppies: Real;
-
- Const
-
- lim = 23; {number of lines before pause}
-
- Procedure Parse_Parm;
-
- Begin
- for i := 1 to paramcount do
- begin
- if (paramstr(i)='/p') or (paramstr(i)='/P') then pause:=true;
- if (pos(':',paramstr(i)) <> 0) and
- (pos('\',paramstr(i)) = 0)
- then sublist[1]:= paramstr(i)+'\';
- end;
- end;
-
- Procedure WaitKey;
-
- Begin
- p := 1;
- writeln;
- writeln ('Press any key to continue...');
- Read(Kbd,ans);
- writeln(' ');
- end;
-
- Function TTime(FTime: Integer): String05;
-
- Var
- FHR,
- FMin : String[2];
- HR : Integer;
-
- Begin;
-
- str ((FTime shr 11):2, FHr);
- str (((FTime shl 5) shr 10):2, FMin);
-
- If FHR[1] = ' ' then FHR[1] := '0';
- If FMin[1] = ' ' then FMin[1] := '0';
-
- TTime := FHR + ':' + FMin;
- End;
-
- Function TDate(FDate: Integer): String08;
-
- Var
- FYr,
- FMo,
- FDay : String[2];
-
- Begin
- str (((FDate shr 9) +80):2, FYr);
- str (((FDate shl 7) shr 12):2, FMo);
- str (((FDate shl 11) shr 11):2, FDay);
-
- If FMo[1] = ' ' then FMo[1] := '0';
- If FDay[1] = ' ' then FDay[1] := '0';
-
- TDate := FMo + '/' + FDay + '/' + FYr;
-
- End;
-
- Function SysDate: String08;
-
- Var
- Month,
- Day,
- Year : string[2];
-
- begin
- Regs.AX := $2A00; { Get System Date }
- MSDos(Regs);
-
- str(Regs.DH: 2,month);
- str(Regs.DL: 2,day);
- str((Regs.CX - 1900): 2,year);
-
- If Month[1] = ' ' Then Month[1] := '0';
- If Day[1] = ' ' Then Day[1] := '0';
-
- SysDate := Month + '/' + Day + '/' + Year;
- End;
-
- Function TSize(FSize1, FSize2, FSize3: Byte): Real;
-
- Var
- RSize1,
- RSize2,
- RSize3 : Real;
-
- Begin
-
- RSize1 := FSize1;
- RSize2 := FSize2 * 256.0;
- RSize3 := FSize3 * 65536.0;
- TSize := RSize1 + RSize2 + RSize3;
-
- End;
-
- Procedure SaveIt(Attr: Byte);
-
- Begin
-
- If (Attr = 16)
- then begin
- If o = 1
- then sublist[k] := sublist[o] + NamR
- else begin
- For I := K downto O + 1
- Do Sublist[I] := Sublist[I-1];
- Sublist[O+1] := sublist[o] + '\' + NamR;
- end;
- k:=k+1;
- end
- else begin
- Files := Files + 1;
- ArcList[Files].FileName := NamR;
- ArcList[Files].FileDate := TDate(DTA.Date);
- ArcList[Files].FileTime := TTime(DTA.Time);
- ArcList[Files].FileSize := TSize(DTA.Size[1],DTA.Size[2],
- DTA.Size[3]);
- Tot_Bytes := Tot_Bytes + ArcList[Files].FileSize;
- end;
- end;
-
- Procedure PrintArc;
-
- Begin
- If Files > 0 then begin
- WriteLn;
- WriteLn('Dir: ',SubList[O]);
- if pause then
- begin
- p := p + 2;
- if p >= lim then waitkey;
- end;
-
- for i := 1 to Files do
- begin
- writeln(' ',ArcList[I].FileName:15,
- ArcList[I].FileDate:12,
- ArcList[I].FileTime:10,
- ArcList[I].FileSize:08:0);
- if pause then begin p:=p+1; if p=lim then waitkey; end;
- end;
- end;
- end;
-
- Procedure getlist;
-
- Begin { main body of program DirList }
-
- FillChar(DTA,SizeOf(DTA),0); { Initialize the DTA buffer }
- FillChar(Mask,SizeOf(Mask),0); { Initialize the mask }
- FillChar(NamR,SizeOf(NamR),0); { Initialize the file name }
-
- Regs.AX := $1A00; { Function used to set the DTA }
- Regs.DS := Seg(DTA); { store the parameter segment in DS }
- Regs.DX := Ofs(DTA); { " " " offset in DX }
- MSDos(Regs);
-
- Mask := '????????.???'; { Use global search }
- Regs.AX := $4E00; { Start file search }
- Regs.DS := Seg(Mask); { Point to the file Mask }
- Regs.DX := Ofs(Mask);
- Regs.CX := 22; { Look for Hidden, System, Directory, Files }
- MSDos(Regs);
-
- If (Regs.AX) > 0 Then Exit;
-
- Repeat
- If (DTA.Attr = 16) or { Directory Entry }
- (DTA.Attr > 31) { Archived Bit Set }
- Then Begin
- I := 1;
- repeat
- NamR[I] := DTA.Name[I];
- I := I + 1;
- until not (NamR[I-1] in [' '..'~']) or (I > 13);
- NamR[0] := Chr(I-2); { set string length because assigning }
- { by element does not set length }
- If NamR[1] <> '.'
- Then SaveIt(DTA.Attr);
- End;
-
- Regs.AX := $4F00; { Continue File Search }
- Regs.CX := 22; { Set the file option }
- MSDos( Regs );
-
- Until (Regs.AX) > 0;
-
- end;
-
- Begin
-
- getdir(0,SaveDir);
- sublist[1] := '\';
- pause := false;
- Parse_Parm;
-
- Tot_Bytes := 0.0;
- K := 1;
- O := 1;
- Tot_Files := 0;
- Tot_Floppies := 0;
- Clrscr;
- WriteLn('List ARChive ..... Ver 1.01 ..... LARC [d:] [/p]',SysDate:10);
- P := 2;
- repeat
- ChDir(SubLIst[o]);
- K := K + 1;
- Files := 0;
- GetList;
- K := K - 1;
- Tot_Files := Tot_Files + Files;
- Printarc;
- O := O + 1;
- until O > K;
- If Tot_Bytes > 0 Then
- Begin
- Tot_Bytes := Tot_Bytes + (Tot_Files * 128);
- Tot_Bytes := Tot_Bytes + ((Tot_Bytes / 362496.0) * 128.0);
- Tot_Floppies := INT(Tot_Bytes / 362496.0) + 1.0;
- End;
- O := O - 1;
- ChDir(SaveDir); {Restore starting Directory}
-
- If Pause
- Then Begin
- If P + 5 >= Lim Then WaitKey;
- end;
-
- writeln('|-----------------------------------------------------|');
- writeln('| Total Directories : ',o:3,' | Total files listed: ',tot_files:5,' |');
- writeln('|-----------------------------------------------------|');
- WriteLn('| Approximately ',Tot_Floppies:3:0,' floppies needed for Backup |');
- Writeln('|-----------------------------------------------------|');
-
- end.