Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arcage/tarball.cr
TAR archive reader of Crystal
https://github.com/arcage/tarball.cr
crystal tar
Last synced: about 2 months ago
JSON representation
TAR archive reader of Crystal
- Host: GitHub
- URL: https://github.com/arcage/tarball.cr
- Owner: arcage
- License: mit
- Created: 2019-06-04T04:21:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-14T01:51:57.000Z (over 5 years ago)
- Last Synced: 2024-10-25T01:36:39.238Z (3 months ago)
- Topics: crystal, tar
- Language: Crystal
- Size: 27 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TAR archive reader for Crystal
This shard makes you to read the TAR archive files(POSIX ustar format and some functions in GNUTAR fomat).
No external library needed. This is written in pure Crystal.
In this version, following entry types are supported:
- Regular file (typeflag: `'\0'` or `'0'`)
- Hardlink (typeflag: `'1'`)
- Symlink (typeflag: `'2'`)
- Directory (typeflag: `'5'`)
- PAX data (typeflag: `'x'`) (**mtime**, **path**, **linkpath**, **uid**, **gid**)
- GNU long path name (typeflag: `'L'`)
- GNU long link name (typeflag: `'K'`)Other entry type will be extracted as a regular file.
Supporting gzipped tar archive file.
## Installation
Add the dependency to your `shard.yml`:
```yaml
dependencies:
tarball:
github: arcage/tarball.cr
```Then, run `shards install`
## Usage
```crystal
require "tarball"# Extracts all files in "archive.tar" to under the "data" directory.
Tarball.extract_all("archive.tar", "data")Tarball.open("archive.tar") do |tar|
# list of included file system objects.
tar.filenames
#=> ["dir/", "dir/file_name.txt", "dir/image.png"]# extract specific file to specific path.
tar.extract_file("dir/file_name.txt", "other_name.txt")# write content data to IO object.
tar.write_content("dir/file_name.txt", STDOUT)
end# open gzipped tar archive
Tarball.open_gz("archive.tar.gz") do |tar|
# ...
end
```## API Documents
- [http://www.denchu.org/tarball.cr/](http://www.denchu.org/tarball.cr/)
## Contributors
- [ʕ·ᴥ·ʔAKJ](https://github.com/arcage) - creator and maintainer