TMyFTPItem = record
a1:string; //文件属性
a2:string; //文件版本=1
a3:string; //文件建立者 ftp
a4:string; //文件拥有者 ftp
a5:string; //文件尺寸
a6:string; //文件建立月份
a7:string; //文件建立日期
a8:string; //文件建立时间 或 年分
a9:string; //文件名称
fdatetime:tdatetime;
end;
function mreadftp(const mftpstr:string;var Myftp:TMyFTPItem):boolean;
var mstr:string; i,j:integer;
mmonth:array [0..11] of string;
begin
result:=false;
if trim(mftpstr)='' then exit;
if not (mftpstr[1] in ['d','-','l']) then exit;
mmonth[0]:='january';
mmonth[1]:='february';
mmonth[2]:='march';
mmonth[3]:='april';
mmonth[4]:='may';
mmonth[5]:='june';
mmonth[6]:='july';
mmonth[7]:='august';
mmonth[8]:='september';
mmonth[9]:='october';
mmonth[10]:='november';
mmonth[11]:='december';
mstr:=Trim(mftpstr+'#');
i:=pos(' ',mstr);
Myftp.a1:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a2:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a3:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a4:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a5:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a6:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
i:=pos(' ',mstr);
Myftp.a7:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
if length(Myftp.a7)=1 then Myftp.a7:='0'+Myftp.a7;
i:=pos(' ',mstr);
Myftp.a8:=copy(mstr,1,i-1); mstr:=trim(copy(mstr,i+1,length(mstr)));
Myftp.a9:=copy(mstr,1,length(mstr)-1);
if pos(':',Myftp.a8)>1 then begin //myftp.a8 as time or as year
for i:=0 to 11 do
if pos(LowerCase(Myftp.a6),mmonth)=1 then
break;
inc(i);
if strtoint(inttostr(i)+Myftp.a7)>strtoint(formatdatetime('mmdd',now)) then
j:=strtoint(formatdatetime('yyyy',now))-1
else j:=strtoint(formatdatetime('yyyy',now));
Myftp.fdatetime:=strtodatetime(inttostr(j)+'-'+inttostr(i)+'-'+Myftp.a7+' '+Myftp.a8);
end else begin
for i:=0 to 11 do
if pos(LowerCase(Myftp.a6),mmonth)=1 then
break;
inc(i);
Myftp.fdatetime:=strtodatetime(Myftp.a8+'-'+inttostr(i)+'-'+Myftp.a7);
end;
//if is linux then add: myftp.fdatetime:=myftp.fdatetime+8/24;
result:=true;
end;