{"id":17921414,"url":"https://github.com/gotson/nightcompress","last_synced_at":"2026-01-19T08:32:30.068Z","repository":{"id":213636343,"uuid":"734573136","full_name":"gotson/NightCompress","owner":"gotson","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-15T10:01:09.000Z","size":196,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T12:55:42.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/gotson.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":"2023-12-22T03:18:00.000Z","updated_at":"2024-05-06T15:06:29.841Z","dependencies_parsed_at":"2024-02-05T17:02:58.180Z","dependency_job_id":"f7d1691e-4f45-4f08-9178-c30792032ead","html_url":"https://github.com/gotson/NightCompress","commit_stats":null,"previous_names":["gotson/nightcompress"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotson%2FNightCompress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotson%2FNightCompress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotson%2FNightCompress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotson%2FNightCompress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotson","download_url":"https://codeload.github.com/gotson/NightCompress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247803836,"owners_count":20998840,"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":[],"created_at":"2024-10-28T20:33:46.311Z","updated_at":"2026-01-19T08:32:30.063Z","avatar_url":"https://github.com/gotson.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/gotson/NightCompress/ci.yml?branch=main\u0026style=flat-square)](https://github.com/gotson/NightCompress/actions/workflows/ci.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.gotson.nightcompress/nightcompress?color=blue\u0026style=flat-square\u0026label=maven%20central)](https://search.maven.org/search?q=g:com.github.gotson.nightcompress)\n![Maven Snapshot](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Fcom%2Fgithub%2Fgotson%2Fnightcompress%2Fnightcompress%2Fmaven-metadata.xml\u0026style=flat-square\u0026label=maven%20snapshot\u0026color=blue)\n\n\n# NightCompress\n\nA Java wrapper around [libarchive](https://libarchive.org/). NightCompress uses the Foreign Linker API\navailable since JDK 22 to access native libraries.\n\n## How it works\n\nNightCompress is released as a multi-release JAR:\n\n- with Java \u003c 22 as a no-op version that throws `UnsupportedOperationException` on any operation\n- with Java 22+ all the features are available\n\nThis lets you add the dependency in your project whatever the JDK used, and still enable the feature at runtime if the required JDK is used. \n\n## Requirements\n\nIn order for the JAR to run properly, you will need to:\n\n- Run Java 22 with the following options:\n\n```\n--enable-native-access=ALL-UNNAMED\n```\n\n- Make sure the path to the directory containing the native libraries is contained in the Java system\n  property `java.library.path` (check\n  also [this](https://stackoverflow.com/questions/20038789/default-java-library-path)).\n  - For Linux, normally it works fine when installed from a package manager. You can add the libraries' path to\n    the `LD_LIBRARY_PATH` environment variable.\n  - For Mac, if using HomeBrew, you will need to set `JAVA_LIBRARY_PATH` to `/usr/local/lib/` or `/opt/homebrew/lib/`.\n\n## Installation\n\n### Gradle\n\n```groovy\nimplementation \"com.github.gotson.nightcompress:nightcompress:{version}\"\n```\n\n### Gradle (Kotlin DSL)\n\n```kotlin\nimplementation(\"com.github.gotson.nightcompress:nightcompress:{version}\")\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.gotson.nightcompress\u003c/groupId\u003e\n  \u003cartifactId\u003enightcompress\u003c/artifactId\u003e\n  \u003cversion\u003e{version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\n### Check if the library is available\n\n```java\ntry {\n  if (Archive.isAvailable()) {\n    // do stuff\n  }\n} catch(Exception e) {\n  // to be on the safe side\n}\n```\n\n### Extract from a `Path` to an `OutputStream`\n```java\n// Assuming you already have a Path pointing to the archive file and an OutputStream for writing to\nArchive archive = new Archive(path);\nwhile (archive.getNextEntry() != null) {\n  try (InputStream is = archive.getInputStream()) {\n    is.transferTo(outputStream);\n  }\n}\n\n// Assuming you already know which entry you want to extract\ntry (InputStream is = Archive.getInputStream(path, entryName)) {\n  is.transferTo(outputStream);\n}\n```\n\n### Specify Compression, Filter, and Format\n\n`libarchive` supports various [formats](https://github.com/libarchive/libarchive/wiki/LibarchiveFormats). You can specify the compression, filter, and formats you want to enable when calling the `Archive` constructor, or the static functions `Archive.getEntries` and `Archive.getInputStream`.\n\nBy default, all will be enabled.\n\nThis can cause issues if you have archives within archives though. For example, if you have a RAR file containing a ZIP file, when all is enabled, `libarchive` would produce entries of the inner ZIP file, instead of the ZIP file entry itself.\n\n```java\n// Enable RAR5 only\nArchive archive = new Archive(path, Set.of(ReadSupportCompression.NONE), Set.of(ReadSupportFilter.NONE), Set.of(ReadSupportFormat.RAR5));\n\nArchive.getInputStream(path, Set.of(ReadSupportCompression.NONE), Set.of(ReadSupportFilter.NONE), Set.of(ReadSupportFormat.RAR5), entryName)\n```\n\n## Configuration\n\nNightCompress allows for some tuning using System Properties:\n\n- Options for `Archive#getInputStream(Path)`:\n  - `nightcompress.extractor.buffer-size`: accepts any positive integer. Defaults to `32 * 1024`.\n    - Sets the maximum size used for the dynamic byte buffer in the `PipedInputStream`.\n  - `nightcompress.extractor.use-executor`: accepts either `true` or `false`. Defaults to `true`.\n    - If `true`, it uses a cached thread pool for extracting the contents, which is generally faster.\n    - If `false`, it will create a new thread on each call. This may be slower, but may require slightly less memory.\n    - Options for tuning the thread pool:\n      - `nightcompress.extractor.max-threads`: accepts any positive integer. Defaults to `2^31`.\n        - Sets the maximum number of threads to be used in the pool. By default, there is no hard limit on the number\n          of threads, but they are only created when needed, so the maximum should not exceed the number of threads\n          calling this method at any given moment. Use this if you need to restrict the number of threads.\n      - `nightcompress.extractor.thread-keep-alive-seconds`: accepts any positive integer. Defaults to `5`.\n        - Sets the number of seconds a thread can be kept alive in the pool, waiting for a next extraction operation.\n          After that time, the thread may be stopped.\n\n## Implementation notes\n\nThe `panama` package bindings were generated using:\n- jextract 22\n- from the https://github.com/libarchive/libarchive/ repository, version 3.5.0\n- based on a synthetic header file:\n  ```\n  #include \"archive.h\"\n  #include \"archive_entry.h\"\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotson%2Fnightcompress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotson%2Fnightcompress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotson%2Fnightcompress/lists"}