{"id":13482688,"url":"https://github.com/naqvis/crystar","last_synced_at":"2025-04-14T06:36:59.941Z","repository":{"id":53546341,"uuid":"195281212","full_name":"naqvis/crystar","owner":"naqvis","description":"Crystal language Tar Module implements access to tar archives.","archived":false,"fork":false,"pushed_at":"2024-06-20T14:11:34.000Z","size":152,"stargazers_count":39,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T20:21:56.207Z","etag":null,"topics":["crystal","crystal-lang","crystal-language","tar","tarball"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naqvis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-04T17:40:02.000Z","updated_at":"2025-02-17T20:45:07.000Z","dependencies_parsed_at":"2024-05-02T19:02:17.986Z","dependency_job_id":"f7b01bc7-48aa-4dde-83d6-8c0dd2a2ee47","html_url":"https://github.com/naqvis/crystar","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcrystar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcrystar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcrystar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naqvis%2Fcrystar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naqvis","download_url":"https://codeload.github.com/naqvis/crystar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248836210,"owners_count":21169367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","crystal-lang","crystal-language","tar","tarball"],"created_at":"2024-07-31T17:01:04.510Z","updated_at":"2025-04-14T06:36:59.901Z","avatar_url":"https://github.com/naqvis.png","language":"Crystal","funding_links":[],"categories":["Compression"],"sub_categories":[],"readme":"# Crystal Tar (Crystar)\n![CI](https://github.com/naqvis/crystar/workflows/CI/badge.svg)\n[![GitHub release](https://img.shields.io/github/release/naqvis/crystar.svg)](https://github.com/naqvis/crystar/releases)\n[![Docs](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://naqvis.github.io/crystar/)\n\nShard `Crystar` implements access to tar archives.\n\n*No external library needed.* This is written in **pure Crystal**.\n\nTape archives (tar) are a file format for storing a sequence of files that can be read and written in a streaming manner. This shard aims to cover most variations of the format, including those produced by **GNU** and **BSD** tar tools.\n\nThis module is mostly based on [`Tar`](https://golang.google.cn/pkg/archive/tar/) package implementation of [Golang](http://golang.org/)\n\n\n  Format represents the tar archive format.\n\n  The original tar format was introduced in Unix V7.\n  Since then, there have been multiple competing formats attempting to\n  standardize or extend the **V7** format to overcome its limitations.\n  The most common formats are the **USTAR**, **PAX**, and **GNU** formats,\n  each with their own advantages and limitations.\n\n  The following table captures the capabilities of each format:\n\n  \t                  |  USTAR |       PAX |       GNU\n  \t------------------+--------+-----------+----------\n  \tName              |   256B | unlimited | unlimited\n  \tLinkname          |   100B | unlimited | unlimited\n  \tSize              | uint33 | unlimited |    uint89\n  \tMode              | uint21 |    uint21 |    uint57\n  \tUid/Gid           | uint21 | unlimited |    uint57\n  \tUname/Gname       |    32B | unlimited |       32B\n  \tModTime           | uint33 | unlimited |     int89\n  \tAccessTime        |    n/a | unlimited |     int89\n  \tChangeTime        |    n/a | unlimited |     int89\n  \tDevmajor/Devminor | uint21 |    uint21 |    uint57\n  \t------------------+--------+-----------+----------\n  \tstring encoding   |  ASCII |     UTF-8 |    binary\n  \tsub-second times  |     no |       yes |        no\n  \tsparse files      |     no |       yes |       yes\n\n  The table's upper portion shows the Header fields, where each format reports\n  the maximum number of bytes allowed for each string field and\n  the integer type used to store each numeric field\n  (where timestamps are stored as the number of seconds since the Unix epoch).\n\n  The table's lower portion shows specialized features of each format,\n  such as supported string encodings, support for sub-second timestamps,\n  or support for sparse files.\n\n  The `Writer` currently provides **no support** for _sparse files_.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     crystar:\n       github: naqvis/crystar\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"crystar\"\n```\n\n`Crystar` module contains readers and writers for tar archive.\nTape archives (tar) are a file format for storing a sequence of files that can be read and written in a streaming manner.\nThis module aims to cover most variations of the format, including those produced by GNU and BSD tar tools.\n\n## Sample Usage\n```crystal\nfiles = [\n  {\"readme.txt\", \"This archive contains some text files.\"},\n  {\"minerals.txt\", \"Mineral names:\\nalunite\\nchromium\\nvlasovite\"},\n  {\"todo.txt\", \"Get crystal mining license.\"},\n]\n\nbuf = IO::Memory.new\nCrystar::Writer.open(buf) do |tw|\n  files.each do |f|\n    hdr = Crystar::Header.new(\n      name: f[0],\n      mode: 0o600_i64,\n      size: f[1].size.to_i64\n    )\n    tw.write_header(hdr)\n    tw.write(f[1].to_slice)\n  end\nend\n#Open and iterate through the files in the archive\nbuf.pos = 0\nCrystar::Reader.open(buf) do |tar|\n  tar.each_entry do |entry|\n    p \"Contents of #{entry.name}\"\n    IO.copy entry.io, STDOUT\n    p \"\\n\"\n  end\nend\n```\n\nSupports compressed archives as well.\n\n```crystal\nrequire \"gzip\"\n\nFile.open(\"test.tar.gz\") do |file|\n  Gzip::Reader.open(file) do |gzip|\n    Crystar::Reader.open(gzip) do |tar|\n      tar.each_entry do |entry|\n        p \"Contents of #{entry.name}\"\n        IO.copy entry.io, STDOUT\n      end\n    end\n  end\nend\n```\n\nRefer to `Crystar::Reader` and `Crystar::Writer` module for documentation on detailed usage.\n\n# Development\n\nTo run all tests:\n\n```\ncrystal spec\n```\n\n# Contributing\n\n1. Fork it (\u003chttps://github.com/naqvis/crystar/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n# Contributors\n\n- [Ali Naqvi](https://github.com/naqvis) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaqvis%2Fcrystar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaqvis%2Fcrystar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaqvis%2Fcrystar/lists"}