Skip to content

About

Delphi/Free Pascal port of Unrar - RAR decompressor

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Repository files navigation

Free Pascal/Delphi port of Unrar

This library allows you to unpack RAR (version 3-5) archives, password protected and not.

Works in Delphi XE and Lazarus

License

MIT The code cannot be used to recreate RAR compression.

Usage

Listing files:

uses Unrar;

var rar: TRarUnpacker;
    ADate: TDateTime;
    ASize: Int64;
    AName: String;
begin

  rar := TRarUnpacker.Create('pass.rar', 'pass');  //can also be pass.exe - RAR SFX
  if not rar.CheckPassword then begin
    ShowMessage('Incorrect password!');
    rar.Free;
    Exit;
  end;

  while rar.NextEntry(AName, ASize, ADate) do begin
    Memo1.Lines.Add(AName);
  end;

  rar.Free;   

Extracting files:

var
  rar : TRarUnpacker;
  ADate: TDateTime;
  ASize: Int64;
  AName: String;
  F    : TFileStream;
  OutDir, FullPath: String;
begin
  OutDir := 'OutputDir\';   // destination directory

  rar := TRarUnpacker.Create('pass.rar', '');
  try
    while rar.NextEntry(AName, ASize, ADate) do
    begin
      Memo1.Lines.Add(AName);

      FullPath := IncludeTrailingPathDelimiter(OutDir) + AName;
      ForceDirectories(ExtractFileDir(FullPath));

      F := TFileStream.Create(FullPath, fmCreate);
      try
        rar.Extract(F);
      finally
        F.Free;
      end;
    end;
  finally
    rar.Free;
  end; 

About

Delphi/Free Pascal port of Unrar - RAR decompressor

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages