Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

morihofi/cab4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗄️ cab4j - Cabinet Files in pure Java

A Java library for creating and reading cabinet files (*.cab) with Java using NIO ByteBuffer. It was created using the official Microsoft CAB Documentation and has almost no dependencies.

✨ Features

  • Checksum supported
  • makes only use of Java NIO2 ByteBuffers
  • Uncompressed, MSZIP, Quantum and LZX compression support
  • Recursive directory packing with subfolder support
  • Splitting archives into multiple cabinets
  • Java 8+ compatible

📃 Testing and official docs

  • Test files are located in test/-Directory, this contains the test cab from the pdf in docu/ directory

File attributes

CabArchive.addFile(Path) automatically records DOS file attributes like read-only or hidden when available. You can also specify attributes manually using

archive.addFile("name.txt", buffer, CfFile.ATTRIB_READONLY | CfFile.ATTRIB_HIDDEN);

Use CabExtractor.extractWithAttributes to retrieve these attributes or extractToDirectory to restore them on disk.

Directory packing

You can add entire directory trees using CabArchive.addDirectory(Path). Relative paths are preserved inside the cabinet. When building large archives you can split the output into multiple cabinets using CabGenerator:

CabArchive archive = new CabArchive();
archive.addDirectory(Paths.get("assets"));
CabGenerator generator = new CabGenerator(archive);
List<ByteBuffer> cabs = generator.createCabinetSet(1_000_000); // split after 1 MB

File timestamps

CabArchive.addFile(Path) also preserves the last modified time of the source file. When extracting with extractWithAttributes the returned ExtractedFile contains this timestamp and extractToDirectory restores it on disk. The time format follows the same semantics as the Java ZIP API.

About

Microsoft Cab writing and readinglibrary using Java NIO - Developmemt continues on Codeberg

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published