2 {Take tracks of files in store}
3 {just simple, no cleaning, etc}
8 tfid
=array [0..19] of byte;
9 tStoreObjectInfo
=object
10 final
:boolean; {hash matched}
11 rc
:Word; {0=no error 1=not found, other}
12 length
:LongWord
; {the whole file}
13 seglen
:longword
; {from cur to end of segment}
15 procedure Open(const fid
:tfid
);
17 procedure SegSeek(ofs
:LongWord
);
18 procedure ReadAhead(cnt
:Word; into
:pointer);
19 procedure WaitRead
; {wait for read to finish, rc}
21 dh
:tHandle
; {handle to the data file}
23 procedure mkfilen(var d
:string; flag
:char; const fid
:tfid
);
27 const prefix
='object';
29 procedure tStoreObjectInfo
.mkfilen(var d
:string; flag
:char; const fid
:tfid
);
30 function hc(b
:byte):char;
32 if b
<10 then hc
:=char(ord('0')+b
)
33 else hc
:=char(ord('A')-10+b
);
41 for i
:=0 to 19 do begin
42 filename
[b
+(i
*2)]:=hc(fid
[i
] shr 4);
43 filename
[b
+(i
*2)+1]:=hc(fid
[i
] and $F);
46 procedure tStoreObjectInfo
.Open(const fid
:tfid
);
48 mkfilen(filename
,'f',fid
);
49 dh
:=FileOpen(filename
,fmOpenRead
or fmShareDenyWrite
);
53 length
:=FileSeek(dh
,0,fsFromEnd
);
54 FileSeek(dh
,0,fsFromBeginning
);
56 Writeln('Store1: open failed for file ',filename
,', ioresult=',IOResult
);
60 procedure tStoreObjectInfo
.ReadAhead(cnt
:Word; into
:pointer);
63 //todo, do real async read
64 red
:=FileRead(dh
,into
^,cnt
);
65 if red
=cnt
then rc
:=0 else begin
67 writeln('Store1: read ',red
,' out of ',cnt
,' requested bytes');
71 procedure tStoreObjectInfo
.WaitRead
; {wait for read to finish, rc}
75 procedure tStoreObjectInfo
.Close
;
79 procedure tStoreObjectInfo
.SegSeek(ofs
:longword
);