2005年3月4日星期五

RPM content plugin for Total Commander

今天有空,在Mandryka Yurij的rpm_wcx源代码基础上完成了rpm content plugin
下载: rpm_wdx-1.00-src.zip

读取包信息部分的代码如下,很简单,是不是?


function ReadRPMInfo(filename: String): integer;
var
fh: integer;
fh_file: file;
r_lead: RPM_Lead;
signature, r_header: RPM_Header;
//r_info: RPM_InfoRec;
begin
Result := -1;
fh := FileOpen(filename, fmOpenRead or fmShareDenyNone);
if fh=-1 then exit;


AssignFile(fh_file, filename);
try
FileMode := 0;
Reset(fh_file, 1);

if IOResult <> 0 then exit;

RPM_ReadLead(fh_file, r_lead);
if r_lead.magic <> RPM_MAGIC then exit;

if not RPM_ReadSignature(fh_file, r_lead.signature_type, signature) then exit;

if not RPM_ReadHeader(fh_file, false, r_header, FileInfoCache) then exit;

Result := 0;
finally
CloseFile(fh_file);

FileClose(fh); //oppsition to FileOpen
end;
end;

没有评论: