Skip to content

kyz/lha.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lha.js

List and unpack LhA archives in the browser

LHA.readFromURL("my_files/foo.lha", function (entries) {
     for (var e in entries) {
         var entry = entries[e];
         var name  = entry.name;         // full path and filename
         var data  = LHA.unpack(entry);  // unpacked data as Uint8Array
     }
})

This Javascript library lets you unpack LhA files in the browser.

LhA files (also known as LHarc files or LZH files) are popular in Japan, and are the standard archive format for Aminet, the world's largest collection of Amiga software.

API Reference

# LHA.readFromURL(url, callback)

Gets a URL using XMLHttpRequest and parses the response as an LhA archive. The callback is called with an array of entries, one for each entry in the archive.

Each entry has these fields:

  • name: the full path and filename
  • packMethod: the method used to compress the file, e.g. -lh1-, -lh5-. The value -lhd- means this entry is a directory rather than a file
  • packedLength: the compressed file size
  • length: the uncompressed file size
  • lastModified: a Date of when the file was last modified
  • comment: an optional comment for the file

# LHA.read(data)

Parses the provided Uint8Array as an LhA archive and returns an array of entries, one for each entry in the archive. Each entry has the same fields as described above.

# LHA.unpack(entry)

Unpacks a file and returns its uncompressed data as a Uint8Array. If this is a text file, you can convert it back a a string with String.fromCharCode or TextDecoder.

About

List and unpack LhA archives in the browser

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published