home *** CD-ROM | disk | FTP | other *** search
- (* This routine reads the directory info on lbr files. I had three lbr
- programs and one used no date or time. The second used date and time
- as it would print 1-1-80 and 14:30:24. The third program LUPower or
- LU used a modified julian date format for the storage of the date.
- The base year was 1-1-1978 which cannot be entered into the PC therefore
- the earliest date was FA02 or reversed 02FA or 731 in modified julian
- format or 731 days since the base date. What it means is 365 days in 1978
- 365 days in 1979 and 1 day in 1980. I have entered routines to handle
- years until 2008.
-
- This module has been written and Copyright (C) by Karson W. Morrison
- Caleb Computing Center
- Written January 1, 1986 RD 1, Box 531,
- Ringoes, NJ. 08551
-
- *)
-
-
- var
- lbropen : boolean;
- LbrFilePosition : integer;
- HeaderLength : byte; { Number of directory records }
- DirectoryPosition : integer; { Directory record I'm on }
- Header_Found : char;
- LbrFileDateStr : string[2];
- LbrFileTimeStr : string[2];
- LbrFileDate : integer;
- LbrFileTime : integer;
-
- function FileName_St : strtype;
- var s : strtype;
- a, i : integer;
- begin
- s := '';
- for I := 1 to 11 do
- begin
- s := s + buf[ LbrFilePosition + I ];
- if I = 8 then
- s := s + '.';
- end;
- FileName_St := s;
- end;
-
-
- procedure Read_Block_Lbr;
- begin
- if EOF(fil) then endfile := TRUE
- else BlockRead(fil, buf, 1);
- LbrFilePosition := 1;
- DirectoryPosition := DirectoryPosition + 1;
- end;
-
-
- function flbropen(var name : strtype) : boolean;
- { only binary I/O supported; }
- begin
- {$I-}
- assign(fil, name);
- {$I+}
- if ioresult <> 0 then begin
- flbropen := FALSE;
- exit;
- end;
-
- {$I-}
- reset(fil);
- {$I+}
- if ioresult <> 0 then begin
- flbropen := FALSE;
- exit
- end;
- endfile := FALSE;
- DirectoryPosition := 0;
- Read_Block_Lbr;
- HeaderLength := integer(buf[15]);
- LbrFilePosition := 33;
- flbropen := TRUE;
- end;
-
- procedure closelbr;
- begin
- close(fil);
- end;
-
- function ReadLbrHdr : boolean;
- { FALSE = eof found; TRUE = header found }
- begin
- header_found := '0';
- repeat
- if LbrFilePosition > 128 then
- begin
- if DirectoryPosition = HeaderLength then
- begin
- ReadLbrHdr := FALSE;
- exit;
- end
- else
- Read_Block_Lbr;
- end
- else
- begin
- if ((buf[ LbrFilePosition + 1 ] = ' ') and
- (buf[ LbrFilePosition + 9 ] = ' '))
- or
- ((buf[ LbrFilePosition + 1 ] = #$00) and
- (buf[ LbrFilePosition + 9 ] = #$00)) then
- begin
- LbrFilePosition := LbrFilePosition + 32
- end
- else
- header_found := '1';
- end;
- until header_found = '1';
- if feof then
- readlbrhdr := FALSE
- else
- begin
- if header_found = '1' then
- readlbrhdr := TRUE
- else
- readlbrhdr := False;
- end;
- end;
-
- procedure openlbr;
- begin
- if not flbropen(arcname) then
- lbropen := FALSE
- else
- lbropen := TRUE;
- end;
-
- procedure FixTime;
- begin
- FileHr := ' ';
- FileMN := ' ';
- Str((LbrFileTime shr 11):2,FileHr);
- FileWork := LbrFileTime shl 5;
- Str((FileWork shr 10):2,FileMN);
- if FileHR[1] = ' ' then
- FileHR[1] := '0';
- if FileMN[1] = ' ' then
- FileMN[1] := '0';
- end;
-
-
- procedure lstlbrfile;
- var
- b, yr, mo, dy : integer;
- s, yrstr, mostr, dystr : string[2];
- fn : strtype;
- rlen : real;
- aorp : char;
- sthold : string[7];
-
- procedure FixDate;
- Const
- Days : Array [1..12] of integer = (0, 31, 59, 90, 120, 151, 181, 212,
- 243, 273, 304, 334);
- { number of days at the end of each month }
- Years : Array [1..30] of integer = (0, 365, 730, 1096, 1461, 1826,
- 2191, 2557, 2922, 3287, 3652,
- 4018, 4383, 4748, 5113, 5479,
- 5844, 6209, 6574, 6940, 7305,
- 7670, 8035, 8400, 8765, 9130,
- 9495, 9861, 10226, 10591);
- { number of days at the end of each year }
- { using 1-1-78 as the base year 1980 is leap
- year and each 4 after except year 2000 }
- var
- leap : integer;
- I : integer;
- Match : boolean;
- yrhold : integer;
-
- begin
- Match := False;
- For I := 30 downto 1 do { start at end of table and work }
- if LbrFileDate > Years[I] then { toward the front }
- begin
- if Match then { if I have already match don't }
- else { reset the year etc. }
- begin
- Match := TRUE;
- YR := I + 77; { base year is 1-1-1978 }
- DY := LbrFileDate - Years[I];
- end;
- end;
- Match := False;
- For I := 12 Downto 1 do { start at end of table and work }
- if DY > Days[I] then { toward the front }
- begin
- if Match then
- else { if I match already don't reset }
- begin { reset the month fields etc. }
- Match := True;
- MO := I;
- DY := DY - Days[I];
- end;
- end;
- str(yr:2,yrstr); { make the data a string }
- str(mo:2,mostr);
- str(dy:2,dystr);
- if dystr[1] = ' ' then dystr[1] := '0';
- if mostr[1] = ' ' then mostr[1] := '0';
- end;
-
- procedure twodig(n : integer);
- begin
- str(n:2, s);
- if s[1] = ' ' then s[1] := '0';
- if s[2] = ' ' then s[2] := '0';
- end;
-
-
- begin
- fn := fileName_St;
- rlen := integer(buf[ LbrFilePosition + 14 ]) * 128;
- if (buf[ LbrFilePosition + 18] = #$00) and { I don't have date or }
- (buf[ LbrFilePosition + 21] = #$00) then { time in the record }
- begin
- MOstr := '00'; DYstr := '00'; YRstr := '00'; { zero out the fields }
- FileHR := '00'; FileMN := '00';
- end
- else
- begin
- if (buf[ LbrFilePosition + 18] = '-') and { the date and time are }
- (buf[ LbrFilePosition + 21] = '-') then { already formatted }
- begin
- MOstr[1] := buf[LbrFilePosition + 16]; { just move the data }
- MOstr[2] := buf[LbrFilePosition + 17]; { into the fields }
- DYstr[1] := buf[LbrFilePosition + 19];
- DYstr[2] := buf[LbrFilePosition + 20];
- YRstr[1] := buf[LbrFilePosition + 22];
- YRstr[2] := buf[LbrFilePosition + 23];
- FileHR[1] := buf[LbrFilePosition + 24];
- FileHR[2] := buf[LbrFilePosition + 25];
- FileMN[1] := buf[LbrFilePosition + 27];
- FileMN[2] := buf[LbrFilePosition + 28];
- MOstr[0] := Chr(2);
- DYstr[0] := Chr(2);
- YRstr[0] := Chr(2);
- FileHR[0] := Chr(2);
- FileMN[0] := Chr(2);
- end
- else
- begin
- LbrFileDateStr[1] := buf[ LbrFilePosition + 18 ];
- LbrFileDateStr[2] := buf[ LbrFilePosition + 19 ];
- LbrFileTimeStr[1] := buf[ LbrFilePosition + 22 ];
- LbrFileTimeStr[2] := buf[ LbrFilePosition + 23 ];
- LbrFileDateStr[0] := Chr(2);
- LbrFileTimeStr[0] := Chr(2);
- LbrFileDate := integer(LbrFileDateStr[1]);
- LbrFileDate := LbrFileDate + (integer(LbrFileDateStr[2]) * 256);
- LbrFileTime := integer(LbrFileTimeStr[1]);
- LbrFileTime := LbrFileTime + (integer(LbrFileTimeStr[2]) * 256);
- FixTime;
- FixDate;
- end;
- end;
- ArcList[ArcSrn] := ReadDrive + fn; { its not really an arc I'm just }
- { reusing the table array }
- for b := length(fn) to 12 do ArcList[ArcSrn] := ArcList[ArcSrn] + ' ';
- ArcList[ArcSrn] := ArcList[ArcSrn] + MOstr + '-';
- ArcList[ArcSrn] := ArcList[ArcSrn] + DYstr + '-';
- ArcList[ArcSrn] := ArcList[ArcSrn] + YRstr + ' ';
- ArcList[ArcSrn] := ArcList[ArcSrn] + FileHR + ':' + FileMN;
- Str(rlen:7:0,sthold);
- ArcList[ArcSrn] := ArcList[ArcSrn] + sthold + ' ';
- end;