https://github.com/jindrapetrik/jxar
Java eXtensible ARchiver
https://github.com/jindrapetrik/jxar
compression xar
Last synced: 2 months ago
JSON representation
Java eXtensible ARchiver
- Host: GitHub
- URL: https://github.com/jindrapetrik/jxar
- Owner: jindrapetrik
- License: lgpl-3.0
- Created: 2015-05-09T20:42:22.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-20T10:32:21.000Z (over 2 years ago)
- Last Synced: 2025-01-20T12:46:06.422Z (4 months ago)
- Topics: compression, xar
- Language: Java
- Homepage:
- Size: 3.63 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jxar
Java port of eXtensible ARchiver (XAR)Original source: https://code.google.com/p/xar/
## Commandline usage
Is is similar to original xar, but some options are not yet implemented
```
Usage: java -jar jxar.jar -[cxt] -f [] ...
--help Prints usage
-c Creates an archive
-x Extracts an archive
-t Lists an archive
-f Specifies an archive to operate on [REQUIRED!]
--toc-cksum Specifies the hashing algorithm to use for xml header verification.
Valid values: none, sha1, and md5
Default: sha1
--dump-toc Has xar dump the xml header into the specified file.
--compression Specifies the compression type to use.
Valid values: none, gzip, bzip2
Default: gzip
--version Print xar's version number
```## Java usage
### Reading
```java
import com.jpexs.xar.Xar;
...
Xar x = new Xar(new File("archive.xar"));
x.extract(new File("out/")); //extract all
System.out.println(x.getToc()); //print TOC
String[] dirs = x.listDirs(); //list all directories
String[] files = x.listFiles(); //list all files
byte[] data = x.getFileData("path/in/archive/test.txt"); //Get uncompressed data of file
```### Writing
```java
import com.jpexs.xar.Xar;
import com.jpexs.xar.nodes.*;
...
Xar x = new Xar(); //Use constructor parameter to change compression and/or checksum type
x.add("dir1/first","file.txt",new File("localfile.txt")); //Add text file
x.add("dir1/first","file2.png",new File("localimage.png")); //Second file
x.addDirectory("dir2/mydir"); //Empty directory//Add file and modify permissions:
Node node = x.add("dir2/special","script.sh",new File("script.sh"));
node.mode = 0777;
node.group = "root";
node.uid = 59;//Add symlink
x.add("dir3",new SymLinkNode("mylink","directory","../dir1"));//Finally:
x.save(new File("archive.xar")); //Save to file```
## Ant usage
XAR archives creation only, using xar task:
```ant
```## Bzip2 compression
To enable Bzip2 compression, add JBZip2 to your class path.
You can download the library here:
https://code.google.com/p/jbzip2/## LZMA compression
LZMA compression is currently unsupported. Maybe in the future.## What else is missing
Other node types than directory/file/symlink.## Authors
- Ported by Jindra Petřík aka JPEXS.
- Original XAR written by Rob Braun.