Skip to content

niekvlessert/unrar-wasm-2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

UnRAR WASM 2026

This repository contains a WebAssembly build of the UnRAR source with a minimal C API for listing and extracting RAR archives in browser and worker environments.

Contents

  • unrar/ — upstream UnRAR source with a CMake build for WASM
  • unrar/wasm/unrar_wasm.cpp — thin C API wrapper
  • build/unrar.js and build/unrar.wasm — generated WASM artifacts

Build

Prerequisites:

  • Emscripten installed (emcmake on PATH)
  • CMake 3.16+

Build:

emcmake cmake -S unrar -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

Exported Functions

The WASM module exports two C functions:

  • rar_list(archivePath, listPath)
    • Writes a newline-separated file list to listPath
    • Returns number of files on success or a negative error code
  • rar_extract_all(archivePath, outDir)
    • Extracts all files into outDir
    • Returns number of files on success or a negative error code

Usage (Worker Example)

importScripts('unrar.js');

const Module = await createUnrarModule({
  locateFile: (p) => new URL(p, self.location.href).toString()
});

Module.FS.mkdir('/work');
Module.FS.writeFile('/work/archive.rar', new Uint8Array(buf));

const listRes = Module.ccall('rar_list', 'number', ['string', 'string'], [
  '/work/archive.rar',
  '/work/list.txt'
]);

Module.FS.mkdir('/out');
const extractRes = Module.ccall('rar_extract_all', 'number', ['string', 'string'], [
  '/work/archive.rar',
  '/out'
]);

Notes

  • Built with ALLOW_MEMORY_GROWTH=1 and MAXIMUM_MEMORY=2GB.
  • Output is suitable for web and worker use (no Node target).

Version

Built from UnRAR source snapshot copied into this repo on 2026-04-07.

Upstream

UnRAR source: https://www.rarlab.com/rar/unrarsrc-7.2.1.tar.gz

License

UnRAR is distributed under the UnRAR license. See the upstream license.txt in the source tree for full terms. *** End Patch去了

About

A new unrar WASM which will work properly in a website worker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages