Skip to content

Commit

Permalink
Enabled native unzip using 7zz in Windows. Os.removeAll sets file to …
Browse files Browse the repository at this point in the history
…be writable first before removing it Windows.
  • Loading branch information
robby-phd committed Oct 27, 2024
1 parent 6df1aee commit 88cd460
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions library/jvm/src/main/scala/org/sireum/Os_Ext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,18 @@ object Os_Ext {

def removeAll(path: String): Unit = if (exists(path)) {
val p = path.value.replace(' ', '␣')
if (isDir(path)) {
if (isDir(path) || osKind != Os.Kind.Win) {
osKind match {
case Os.Kind.Win => proc"""cmd /c RD /S /Q $p""".run()
case _ => proc"""sh -c rm␣-fR␣"$p"""".run()
}
} else try {
if (Os.isWin) {
val f = toIO(path)
if (!f.canWrite) {
f.setWritable(false)
}
}
remove(path)
} catch {
case _: Throwable =>
Expand Down Expand Up @@ -794,16 +800,14 @@ object Os_Ext {
}

def unzip(path: String, target: String): Unit = {
if (!Os.isWin) {
p7zzOpt match {
case Some(p) =>
val t = Os.path(target)
t.mkdirAll()
Os.proc(ISZ[String]("bash", "-c", s"${p.name} x -aoa \"$path\"")).
env(ISZ("PATH" ~> s"${p.up.canon}${Os.pathSep}${Os.env("PATH")}")).at(t).runCheck()
return
case _ =>
}
p7zzOpt match {
case Some(p) =>
val t = Os.path(target)
t.mkdirAll()
Os.proc(ISZ[String]("bash", "-c", s"${p.name} x -aoa \"$path\"")).
env(ISZ("PATH" ~> s"${p.up.canon}${Os.pathSep}${Os.env("PATH")}")).at(t).runCheck()
return
case _ =>
}
val zis = new ZIS(new BIS(JFiles.newInputStream(toNIO(path)), buffSize))
try {
Expand Down

0 comments on commit 88cd460

Please sign in to comment.