{"id":13800721,"url":"https://github.com/gonearewe/SevenZ4S","last_synced_at":"2025-05-13T09:31:53.495Z","repository":{"id":54753508,"uuid":"328593249","full_name":"gonearewe/SevenZ4S","owner":"gonearewe","description":"SevenZip library for Scala, easy to use. ","archived":false,"fork":false,"pushed_at":"2021-02-01T02:27:22.000Z","size":1150,"stargazers_count":44,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T15:54:39.462Z","etag":null,"topics":["7zip","compression","scala","scala-library","sevenzip"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gonearewe.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}},"created_at":"2021-01-11T08:15:26.000Z","updated_at":"2023-11-29T07:44:12.000Z","dependencies_parsed_at":"2022-08-14T01:50:24.982Z","dependency_job_id":null,"html_url":"https://github.com/gonearewe/SevenZ4S","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonearewe%2FSevenZ4S","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonearewe%2FSevenZ4S/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonearewe%2FSevenZ4S/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonearewe%2FSevenZ4S/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonearewe","download_url":"https://codeload.github.com/gonearewe/SevenZ4S/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913223,"owners_count":21983277,"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":["7zip","compression","scala","scala-library","sevenzip"],"created_at":"2024-08-04T00:01:15.566Z","updated_at":"2025-05-13T09:31:50.739Z","avatar_url":"https://github.com/gonearewe.png","language":"Scala","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Archive and Compression"],"readme":"# SevenZ4S\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/fun.mactavish/sevenz4s/badge.svg)](https://maven-badges.herokuapp.com/maven-central/fun.mactavish/sevenz4s/)\n[![Scaladoc](https://img.shields.io/badge/scaladoc-latest-blue.svg)](https://gonearewe.github.io/SevenZ4S/fun/mactavish/sevenz4s/index.html)\n[![GitHub stars](https://img.shields.io/github/stars/gonearewe/SevenZ4S.svg?label=Stars)](https://github.com/gonearewe/SevenZ4S)\n[![GitHub forks](https://img.shields.io/github/forks/gonearewe/SevenZ4S.svg?label=Fork)](https://github.com/gonearewe/SevenZ4S)\n[![GitHub issues](https://img.shields.io/github/issues/gonearewe/SevenZ4S.svg?label=Issue)](https://github.com/gonearewe/SevenZ4S/issues)\n[![license](https://img.shields.io/github/license/gonearewe/SevenZ4S.svg)](https://github.com/gonearewe/SevenZ4S/master/LICENSE)\n\n# Introduction\n\nThis a 7Z compression library for Scala(v2.13), providing simple api to create, update\nand extract archives of different formats.\n\nThis library offers compression and update abilities for 5 formats:\n\n```\n7-Zip\tZip\t GZip\tTar\t BZip2\n```\n\nAs for extraction, following formats are all supported:\n\n```\n7-Zip\tZip\tRar\tTar\t Split\tLzma   Iso\tHFS\t GZip\nCpio\tBZip2\tZ\t Arj\tChm\t   Lhz\tCab\t Nsis\nAr/A/Lib/Deb\tRpm\t Wim\tUdf\t   Fat\tNtfs\n```\n\nMultiple platforms are also supported.\n\nThis project is based on [net.sf.sevenzipjbinding](http://sevenzipjbind.sourceforge.net/index.html),\nwhich is a 7z binding library for java. You may acquire more info from its homepage.\nAlso, it's [licensed](https://github.com/borisbrodski/sevenzipjbinding/blob/master/License.txt)\n under LGPL and unRAR restriction.\n\n# Quick Start\n\nFor creating archives, you need to first acquire an instance of concrete\n`ArchiveCreator`. There're 5 kinds of `ArchiveCreator`, one for each format.\nSome features and callback hooks may be optional. Archive is composed of many\nentries, you need to pass some to `compress` method to finish compression.\nObject `SevenZ4S` provides some utils that may help gain entries from local\nfile system.\n\n```scala\n  val path: Path = new File(getClass.getResource(\"/root\").getFile).toPath\n\n  def create7Z(): Unit = {\n    val entries = SevenZ4S.get7ZEntriesFrom(path)\n    new ArchiveCreator7Z()\n      .towards(path.resolveSibling(\"root.7z\"))\n      // archive-relevant features\n      .setLevel(5)\n      .setSolid(true)\n      .setHeaderEncryption(true)\n      .setPassword(\"12345\")\n      .setThreadCount(3)\n      .onEachEnd {\n        ok =\u003e\n          if (ok)\n            println(\"one success\")\n          else\n            println(\"one failure\")\n      }.onProcess {\n      (completed, total) =\u003e\n        println(s\"$completed of $total\")\n    }.compress(entries)\n  }\n```\n\n7Z engine offers abilities to modify, append and remove a few entries\nin a more efficient way. Use `ArchiveUpdater` to update archive instead of\nextract-modify-compress by yourself.\n\n```scala\n  // import ...\n  import fun.mactavish.sevenz4s.Implicits._\n  \n  def update7Z(): Unit = {\n    val replacement = path.resolveSibling(\"replace.txt\")\n\n    val updater = new ArchiveUpdater7Z()\n      .from(path.resolveSibling(\"root.7z\")) // update itself\n      .withPassword(\"12345\")\n      .update {\n        entry =\u003e\n          if (entry.path == \"root\\\\a.txt\") { // path separator is OS-relevant\n            entry.copy(\n              dataSize = Files.size(replacement), // remember to update size\n              source = replacement, // implicit conversion happens here\n              path = \"root\\\\a replaced.txt\" // file name contains space\n            )\n          } else {\n            entry\n          }\n      }\n\n    updater.removeWhere(entry =\u003e entry.path == \"root\\\\sub\\\\deeper\\\\c.txt\")\n    // directory can not be deleted until its contents have all been deleted,\n    // otherwise, it ignores the request silently rather than raise an exception.\n    updater.removeWhere(entry =\u003e entry.path == \"root\\\\sub\\\\deeper\")\n    updater += SevenZ4S.get7ZEntriesFrom(replacement).head\n    // notice that file with the same name is allowed,\n    // but may be overwritten by OS's file system during extraction\n    updater += SevenZ4S.get7ZEntriesFrom(replacement).head\n  }\n```\n\nUnlike `ArchiveCreator` and `ArchiveUpdater`, SevenZ4S provides a generic\n`ArchiveExtractor` supporting the extraction of all formats. It can\nautodetect the format of input archive.\n\n```scala\n  def extract7Z(): Unit = {\n    new ArchiveExtractor()\n      .from(path.resolveSibling(\"root.7z\"))\n      .withPassword(\"12345\")\n      .onEachEnd(println(_))\n      .foreach { entry =\u003e\n        println(entry.path)\n        if (entry.path == \"root\\\\b.txt\") {\n          // extract independently\n          entry.extractTo(path.resolveSibling(\"b extraction.txt\"))\n        }\n      }\n      // `extractTo` takes output folder `Path` as parameter\n      // `onEachEnd` callback only triggers on `extractTo`\n      .extractTo(path.resolveSibling(\"extraction\"))\n      .close() // ArchiveExtractor requires closing\n  }\n```\n\nIf all you want is simply compressing and extracting files on local file\nsystem, the object `SevenZ4S` provides super useful utilities.\n\n```scala\n  val path: Path = new File(getClass.getResource(\"/root\").getFile).toPath\n\n  def test7Z(): Unit = {\n    val output = path.resolveSibling(\"util test/7z\")\n\n    SevenZ4S.compress(ArchiveFormat.SEVEN_Z, path, output)\n    val f = output.resolve(\"root.7z\")\n\n    SevenZ4S.extract(f, output)\n  }\n```\n\nRefer to the test cases and test resources for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonearewe%2FSevenZ4S","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonearewe%2FSevenZ4S","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonearewe%2FSevenZ4S/lists"}