Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
counter2015 committed Nov 22, 2024
1 parent e015bec commit 51c38d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions os/src/ZipOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,23 @@ object zip {

val fis = if (os.isFile(file)) Some(os.read.inputStream(file)) else None

val path = if (os.isDir(file)) sub.toString + "/" else sub.toString
try makeZipEntry0(path, fis, mtimeOpt, zipOut)
try makeZipEntry0(sub, fis, mtimeOpt, zipOut)
finally fis.foreach(_.close())
}

private def makeZipEntry0(
path: String,
sub: os.SubPath,
is: Option[java.io.InputStream],
preserveMtimes: Option[Long],
zipOut: ZipOutputStream
) = {
val path = is match {
// for folder
case None => sub.toString + "/"
// for file
case Some(_) => sub.toString
}

val zipEntry = new ZipEntry(path)

preserveMtimes match {
Expand Down

0 comments on commit 51c38d8

Please sign in to comment.