Skip to content

Commit

Permalink
Integrate Zipper to ScZip
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchesc committed Aug 1, 2018
1 parent 14c4594 commit 9267583
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Using Java NIO.

```scala
// Add files recursively and make zip data.
ScZip.zipTreeToFile(Paths.get("./project"), Paths.get("out.zip"))
.foreach(println) // print entry files
val list: Seq[String] = ScZip.zipTreeToFile(Paths.get("./project"), Paths.get("out.zip"))
list.foreach(println) // entry files

// Can get zip data instead of file
val data = ScZip.zipTreeToBytes(Paths.get("./project"))
val data: Array[Byte] = ScZip.zipTreeToBytes(Paths.get("./project"))
println(data.length)

// Set exclude condition by glob pattern without "glob:".
Expand All @@ -32,7 +32,7 @@ Please append it in your libraryDependencies :)

```scala
libraryDependencies ++= Seq(
"com.yuchesc" %% "sczip" % "0.9.5"
"com.yuchesc" %% "sczip" % "1.0.0"
)
```

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "sczip"

version := "0.9.5"
version := "1.0.0"

organization := "com.yuchesc"

Expand Down
14 changes: 6 additions & 8 deletions src/main/scala/com/yuchesc/sczip/ScZip.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ object ScZip {
* @return entry name list
*/
def zipTree(targetPath: Path, out: OutputStream, exclude: Option[Condition] = None): Seq[String] = {
ScZip.withResource(out, {
zip =>
zip.addTree(targetPath, exclude)
ScZip.withResource(out, { zip =>
zip.addTree(targetPath, exclude)
})
}

Expand Down Expand Up @@ -181,19 +180,18 @@ object ScZip {
* @return entry name list
*/
def zipFiles(files: Seq[Path], out: OutputStream): Seq[String] = {
ScZip.withResource(out, {
zip =>
ScZip.withResource(out, { zip =>
files.map(zip.add)
})
}

def main(args: Array[String]): Unit = {
// Add files recursively and make zip data.
ScZip.zipTreeToFile(Paths.get("./project"), Paths.get("out.zip"))
.foreach(println) // print entry files
val list: Seq[String] = ScZip.zipTreeToFile(Paths.get("./project"), Paths.get("out.zip"))
list.foreach(println) // entry files

// Can get zip data instead of file
val data = ScZip.zipTreeToBytes(Paths.get("./project"))
val data: Array[Byte] = ScZip.zipTreeToBytes(Paths.get("./project"))
println(data.length)

// Set exclude condition by glob pattern without "glob:".
Expand Down

0 comments on commit 9267583

Please sign in to comment.