Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Latest commit

 

History

History
63 lines (57 loc) · 2.94 KB

readme.md

File metadata and controls

63 lines (57 loc) · 2.94 KB

Introduction

UnRAR is the official library from RARLabs for extracting WinRAR archives. This project implements UnRAR bindings for RealStudio and Xojo Win32 applications. Creating archives is not supported by the library.

Synopsis

The project consists of a module containing three classes: Iterator, IteratorEx, and ArchiveEntry.

The Iterator class implements the basic, older UnRAR interface. It does not support Unicode filenames, archives with encrypted headers, or extracting into memory. For almost all archives you should prefer the IteratorEx class.

Example

This example extracts an entire RAR archive into a directory

  Dim archive As FolderItem ' assume a valid RAR archive
  Dim outputdir As FolderItem ' assume a valid directory
  Dim rar As New UnRAR.IteratorEx(archive)
  Do
    If Not rar.MoveNext(UnRAR.RAR_EXTRACT, outputdir) Then Exit Do
  Loop
  rar.Close

How to incorporate RB-RAR into your Realbasic/Xojo project

Import the UnRAR module

  1. Download the RB-RAR project either in ZIP archive format or by cloning the repository with your Git client.
  2. Open the RB-RAR project in REALstudio or Xojo. Open your project in a separate window.
  3. Copy the UnRAR module into your project and save.

Ensure the UnRAR.dll shared library is installed

You will need to ship the UnRAR.dll file with your application and install it into the same directory as your app. A pre-built Win32 DLL is available here, or you can build it yourself from source.

More examples

Extract a single file

  Dim index As Integer = 2 ' the third file in the archive
  Dim archive As FolderItem ' assume a valid RAR archive
  Dim outputfile As FolderItem ' assume a valid, non-existing file
  Dim rar As New UnRAR.IteratorEx(archive)
  rar.Reset(index) ' move to the index
  Call rar.MoveNext(UnRAR.RAR_EXTRACT, outputfile)
  rar.Close

Test an entire archive

  Dim archive As FolderItem ' assume a valid RAR archive
  Dim rar As New UnRAR.IteratorEx(archive)
  Do
    If Not rar.MoveNext(UnRAR.RAR_TEST) Then Exit Do
  Loop
  If rar.LastError <> UnRAR.ErrorEndArchive Then 
    MsgBox("Test failed!")
  End If
  rar.Close

Test a single file

  Dim index As Integer = 2 ' the third file in the archive
  Dim archive As FolderItem ' assume a valid RAR archive
  Dim rar As New UnRAR.IteratorEx(archive)
  rar.Reset(index) ' move to the index  
  If Not rar.MoveNext(UnRAR.RAR_TEST) And rar.LastError <> UnRAR.ErrorEndArchive Then 
    MsgBox("Test failed!")
  End If
  rar.Close