下载: 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;
FileClose(fh); //oppsition to FileOpen
finally
CloseFile(fh_file);
end;
end;
没有评论:
发表评论