This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
168 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
0.3 | ||
0.4 | ||
https://github.com/soywiz/vitaorganizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3 | ||
0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.soywiz.util | ||
|
||
object OS { | ||
private val OS = System.getProperty("os.name").toLowerCase() | ||
|
||
val isWindows: Boolean get() = OS.indexOf("win") >= 0 | ||
val isMac: Boolean get() = OS.indexOf("mac") >= 0 | ||
val isUnix: Boolean get() = OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 | ||
val isSolaris: Boolean get() = OS.indexOf("sunos") >= 0 | ||
val os: String | ||
get() = if (isWindows) "win" | ||
else if (isMac) "osx" | ||
else if (isUnix) "uni" | ||
else if (isSolaris) "sol" | ||
else "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.soywiz.vitaorganizer.tasks | ||
|
||
import com.soywiz.vitaorganizer.FileSize | ||
import com.soywiz.vitaorganizer.GameEntry | ||
import com.soywiz.vitaorganizer.VitaOrganizer | ||
import java.io.ByteArrayOutputStream | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.io.FileOutputStream | ||
import java.util.zip.* | ||
|
||
class RepackVpkTask(val entry: GameEntry, val compression: Int = Deflater.BEST_COMPRESSION, val setSecure: Boolean? = null) : VitaTask() { | ||
override fun perform() { | ||
status("Repacking vpk...") | ||
val file = entry.vpkLocalFile!! | ||
val tempFile = File("${file.absolutePath}.temp") | ||
val tempFile2 = File("${file.absolutePath}.temp2") | ||
|
||
val temp = ByteArray(10 * 1024 * 1024) | ||
|
||
ZipFile(file).use { zip -> | ||
FileOutputStream(tempFile).use { out -> | ||
ZipOutputStream(out).use { zout -> | ||
zout.setLevel(compression) | ||
val entries = zip.entries().toList().distinctBy { it.name } | ||
var currentSize = 0L | ||
val totalSize = entries.map { it.size }.sum() | ||
|
||
for ((index, e) in entries.withIndex()) { | ||
|
||
fun updateStatus() { | ||
status("Repacking ${index}/${entries.size} :: ${FileSize.toString(currentSize)}/${FileSize.toString(totalSize)}") | ||
progress(index, entries.size) | ||
} | ||
|
||
updateStatus() | ||
zout.putNextEntry(ZipEntry(e.name)) | ||
if (e.name == "eboot.bin" && setSecure != null) { | ||
val full = zip.getInputStream(e).readBytes() | ||
if (setSecure) { | ||
full[0x80] = (full[0x80].toInt() and 1.inv()).toByte() // Remove bit 0 | ||
} else { | ||
full[0x80] = (full[0x80].toInt() or 1).toByte() // Set bit 0 | ||
} | ||
zout.write(full) | ||
currentSize += full.size | ||
} else { | ||
zip.getInputStream(e).use { | ||
var localSize = 0L | ||
while (it.available() > 0) { | ||
val bytes = it.read(temp) | ||
if (bytes <= 0) break | ||
zout.write(temp, 0, bytes) | ||
currentSize += bytes | ||
localSize += bytes | ||
if (localSize >= 1 * 1024 * 1024) { | ||
localSize -= 1 * 1024 * 1024 | ||
updateStatus() | ||
} | ||
} | ||
} | ||
updateStatus() | ||
} | ||
|
||
zout.closeEntry() | ||
} | ||
} | ||
} | ||
} | ||
status("Done...") | ||
|
||
file.renameTo(tempFile2) | ||
tempFile.renameTo(file) | ||
tempFile2.delete() | ||
entry.entry.delete() // flush this info! | ||
|
||
VitaOrganizer.updateFileList() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters