⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abzipper.pas

📁 Lazarus is a free and open source development tool for the FreePascal Compiler. The purpose of the p
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  if Assigned(FOnSave) then    FOnSave(Self);end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.FreshenFiles(const FileMask : string);  {freshen all items that match the file mask}begin  if (ZipArchive <> nil) then    ZipArchive.FreshenFiles( FileMask )  else    raise EAbNoArchive.Create;  DoChange;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.FreshenFilesEx(const FileMask, ExclusionMask : string);  {freshen all items matching FileMask except those matching ExclusionMask}begin  if (ZipArchive <> nil) then    ZipArchive.FreshenFilesEx( FileMask, ExclusionMask )  else    raise EAbNoArchive.Create;  DoChange;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.FreshenTaggedItems;  {freshen all tagged items}begin  if (ZipArchive <> nil) then    ZipArchive.FreshenTaggedItems  else    raise EAbNoArchive.Create;  DoChange;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.InitArchive;begin  inherited InitArchive;  if (ZipArchive <> nil) then begin    if (ZipArchive is TAbZipArchive) then begin      {properties}      ZipArchive.AutoSave                              := FAutoSave;      TAbZipArchive(ZipArchive).CompressionMethodToUse := FCompressionMethodToUse;      TAbZipArchive(ZipArchive).DeflationOption        := FDeflationOption;      FArchive.DOSMode                                 := FDOSMode;      ZipArchive.StoreOptions                          := FStoreOptions;      {events}      ZipArchive.OnArchiveSaveProgress                 := DoArchiveSaveProgress; {!!.04}      ZipArchive.OnConfirmSave                         := DoConfirmSave;      TAbZipArchive(ZipArchive).OnRequestBlankDisk     := OnRequestBlankDisk;      ZipArchive.OnSave                                := DoSave;      TAbZipArchive(ZipArchive).InsertHelper           := ZipProc;      TAbZipArchive(ZipArchive).InsertFromStreamHelper := ZipFromStreamProc;    end;  end;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.Move(aItem : TAbArchiveItem; NewStoredPath : string);  {renames the item}begin  if (ZipArchive <> nil) then    ZipArchive.Move(aItem, NewStoredPath)  else    raise EAbNoArchive.Create;  DoChange;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.Replace(aItem : TAbArchiveItem);  {replace the item}begin  if (ZipArchive <> nil) then    ZipArchive.Replace( aItem )  else    raise EAbNoArchive.Create;  DoChange;                                                            end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.Save;begin  if (ZipArchive <> nil) then begin    ZipArchive.Save;    DoChange;  end;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetAutoSave(Value : Boolean);begin  FAutoSave := Value;  if (ZipArchive <> nil) then    ZipArchive.AutoSave := Value;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetCompressionMethodToUse(  Value : TAbZipSupportedMethod);begin  FCompressionMethodToUse := Value;  if (ZipArchive <> nil) then    (ZipArchive as TAbZipArchive).CompressionMethodToUse := Value;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetDeflationOption(Value : TAbZipDeflationOption);begin  FDeflationOption := Value;  if (ZipArchive <> nil) then    (ZipArchive as TAbZipArchive).DeflationOption := Value;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetDOSMode(Value : Boolean);begin  FDOSMode := Value;  if (ZipArchive <> nil) then    ZipArchive.DOSMode := Value;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetFileName(const aFileName : string);var  ArcType : TAbArchiveType;begin  FFileName := aFileName;  if (csDesigning in ComponentState) then    Exit;  try    if Assigned(FArchive) then      FArchive.Save;  except    raise;  end;  FArchive.Free;  FArchive := nil;  ArcType := ArchiveType;  if (FileName <> '') then    if FileExists(FileName) then begin { open it }    if not ForceType then      ArcType := AbDetermineArcType(FileName, atUnknown);      case ArcType of        atZip, atSpannedZip, atSelfExtZip : begin                        {!!.02}         FArchive := TAbZipArchive.Create(FileName, fmOpenRead or fmShareDenyNone);         InitArchive;        end;        atTar : begin          FArchive := TAbTarArchive.Create(FileName, fmOpenReadWrite or fmShareDenyNone);          inherited InitArchive;        end;        atGZip : begin          FArchive := TAbGzipArchive.Create(FileName, fmOpenReadWrite or fmShareDenyNone);          TAbGzipArchive(FArchive).TarAutoHandle := FTarAutoHandle;          TAbGzipArchive(FArchive).IsGzippedTar := False;          inherited InitArchive;        end;        atGZippedTar : begin          FArchive := TAbGzipArchive.Create(FileName, fmOpenReadWrite or fmShareDenyNone);          TAbGzipArchive(FArchive).TarAutoHandle := FTarAutoHandle;          TAbGzipArchive(FArchive).IsGzippedTar := True;          inherited InitArchive;        end;        else          raise EAbUnhandledType.Create;      end {case};      FArchive.Load;      FArchiveType := ArcType;    end else begin  { file doesn't exist, so create a new one }      if not ForceType then                                              {!!.01}        ArcType := AbDetermineArcType(FileName, atUnknown);              {!!.01}      case ArcType of                                                    {!!.01}        atZip : begin                                                              FArchive := TAbZipArchive.Create(FileName, fmCreate);          InitArchive;        end;        atTar : begin          FArchive := TAbTarArchive.Create(FileName, fmCreate or fmShareDenyNone);          inherited InitArchive;        end;        atGZip : begin          FArchive := TAbGzipArchive.Create(FileName, fmCreate or fmShareDenyNone);          TAbGzipArchive(FArchive).TarAutoHandle := FTarAutoHandle;          TAbGzipArchive(FArchive).IsGzippedTar := False;          inherited InitArchive;        end;        atGZippedTar : begin          FArchive := TAbGzipArchive.Create(FileName, fmCreate or fmShareDenyNone);          TAbGzipArchive(FArchive).TarAutoHandle := FTarAutoHandle;          TAbGzipArchive(FArchive).IsGzippedTar := True;          inherited InitArchive;        end;        else          raise EAbUnhandledType.Create;      end {case};      FArchiveType := ArcType;    end;  DoChange;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetStoreOptions(Value : TAbStoreOptions);begin  FStoreOptions := Value;  if (ZipArchive <> nil) then    ZipArchive.StoreOptions := Value;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.SetZipfileComment(Value : string);begin  if (ZipArchive <> nil) then    (ZipArchive as TAbZipArchive).ZipfileComment := Value  else    raise EAbNoArchive.Create;end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.ZipProc(Sender : TObject; Item : TAbArchiveItem;  OutStream : TStream);begin  AbZip(TAbZipArchive(Sender), TAbZipItem(Item), OutStream);end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.ZipFromStreamProc(Sender : TObject; Item : TAbArchiveItem;  OutStream, InStream : TStream);begin  if Assigned(InStream) then    AbZipFromStream(TAbZipArchive(Sender), TAbZipItem(Item),                    OutStream, InStream)  else    raise EAbZipNoInsertion.Create;end;{ -------------------------------------------------------------------------- }{!!.04 - Added}procedure TAbCustomZipper.DoArchiveSaveProgress(Sender : TObject;                                                Progress : Byte;                                                var Abort : Boolean);begin  Abort := False;  if Assigned(FArchiveSaveProgressMeter) then    FArchiveSaveProgressMeter.DoProgress(Progress);  if Assigned(FOnArchiveSaveProgress) then    FOnArchiveSaveProgress(Self, Progress, Abort);end;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.Notification(Component: TComponent;                                       Operation: TOperation);begin  inherited Notification(Component, Operation);  if (Operation = opRemove) then    if Component = FArchiveSaveProgressMeter then      FArchiveSaveProgressMeter := nilend;{ -------------------------------------------------------------------------- }procedure TAbCustomZipper.ResetMeters;begin  inherited ResetMeters;  if Assigned(FArchiveSaveProgressMeter) then    FArchiveSaveProgressMeter.Reset;end;{!!.04 - Added end}{ -------------------------------------------------------------------------- }end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -