Тема: формат файлов в каталоге archive
вот такой:
{$APPTYPE CONSOLE}
uses windows, sysutils;
function readint(fh: THandle): longint;
begin if FileRead(fh, result, sizeof(result)) <> sizeof(result) then result:= -1; end;
function readstr(fh: THandle; maxlen: longint): ansistring;
var tmpc : ansichar;
i : longint;
begin
i:= 0;
setlength(result, maxlen);
while (FileRead(fh, tmpc, sizeof(tmpc)) = sizeof(tmpc)) and (tmpc <> #0) do
if (i < maxlen) then begin
inc(i);
result[i]:= tmpc;
end;
setlength(result, i);
end;
function convertdatetime(adate, atime: longint): tDateTime;
var y, m, d : integer;
h, mi, s : integer;
begin
d:= adate mod 100; adate:= adate div 100;
m:= adate mod 100; adate:= adate div 100;
y:= adate;
s:= atime mod 100; atime:= atime div 100;
mi:= atime mod 100; atime:= atime div 100;
h:= atime;
result:= encodedate(y, m , d) + encodetime(h, mi, s, 0);
end;
type tCandle = packed record
o, h, l, c, v : double;
d, t : longint;
end;
var fname : ansistring;
fh : THandle;
cndl : tCandle;
len : longint;
begin
fname:= paramstr(1);
if fileexists(fname) then begin
fh:= FileOpen(fname, fmOpenRead or fmShareDenyNone);
try
writeln('ver: ', readint(fh));
writeln('ID: ', readstr(fh, 4096));
repeat
len:= FileRead(fh, cndl, sizeof(cndl));
if len = sizeof(cndl) then
with cndl do
writeln(format('o: %.5f h: %.5f l: %.5f c: %.5f v: %.5f ts: %s',
[o, h, l, c, v, formatdatetime('DD-MM-YYYY HH:NN:SS', convertdatetime(d, t))]));
until len <> sizeof(cndl);
finally FileClose(fh); end;
end else writeln('File ', fname, ' not found!');
end.