Skip to content

Commit

Permalink
add support for rar files
Browse files Browse the repository at this point in the history
  • Loading branch information
memo33 committed Mar 22, 2024
1 parent 4d9e28d commit 0149f63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased]
### Added
- support for extracting `.rar` files

### Fixed
- The path to the file `sc4pac.bat` may now contain spaces.
- an issue when extracting 7zip files or exe installers containing multiple folders
Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/sc4pac/extractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ object Extractor {

private object WrappedArchive {
def apply(file: java.io.File, fallbackFilename: Option[String]): WrappedArchive[?] = {
if (file.getName.toLowerCase.endsWith(".exe") || fallbackFilename.exists(_.toLowerCase.endsWith(".exe"))) // assume NSIS installer (ClickTeam installer is not supported)
val lcNames: Seq[String] = Seq(file.getName.toLowerCase) ++ fallbackFilename.map(_.toLowerCase)
if (lcNames.exists(_.endsWith(".exe")) || // assume NSIS installer (ClickTeam installer is not supported)
lcNames.exists(_.endsWith(".rar")))
try {
import net.sf.sevenzipjbinding as SZ
val raf = new java.io.RandomAccessFile(file, "r")
Expand All @@ -29,7 +31,7 @@ object Extractor {
case e: java.lang.UnsatisfiedLinkError => // some platforms may be unsupported, e.g. Apple arm
throw new ExtractionFailed(s"Failed to load native 7z library.", e.toString)
}
else if (file.getName.toLowerCase.endsWith(".7z") || fallbackFilename.exists(_.toLowerCase.endsWith(".7z")))
else if (lcNames.exists(_.endsWith(".7z")))
new Wrapped7z(new SevenZFile(file))
else {
val remoteOrLocalFallback: Option[String] =
Expand Down

0 comments on commit 0149f63

Please sign in to comment.