This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
8c31537
commit d08cae7
Showing
4 changed files
with
63 additions
and
34 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
33 changes: 33 additions & 0 deletions
33
src/io/github/teddyxlandlee/nios/filesplit/util/ByteFileExecutor.kt
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,35 @@ | ||
package io.github.teddyxlandlee.nios.filesplit.util | ||
|
||
import io.github.teddyxlandlee.nios.filesplit.fsplitinfoHeader | ||
import java.io.InputStream | ||
import java.nio.charset.StandardCharsets | ||
|
||
fun infoFromStream(inputStream: InputStream) : Fsplitinfo { | ||
var iCache: Int | ||
val maxFilenameCount: Int | ||
var cache = ByteArray(4) | ||
|
||
iCache = inputStream.read(cache, 0, 4) | ||
if (iCache != 4 || toInt(cache) != fsplitinfoHeader) | ||
throw InvalidFileException("INFO.fsplitinfo", 0x00000002) | ||
|
||
iCache = inputStream.read() | ||
if (iCache < 1) | ||
throw InvalidFileException("INFO.fsplitinfo", 0x00000003) | ||
|
||
iCache = inputStream.read(cache, 0, 4) | ||
if (iCache != 4) | ||
throw InvalidFileException("INFO.fsplitinfo", 0x00000006) | ||
maxFilenameCount = toInt(cache) | ||
|
||
iCache = inputStream.read(cache, 0, 4) | ||
if (iCache != 4) | ||
throw InvalidFileException("INFO.fsplitinfo", 0x00000004) | ||
iCache = toInt(cache) | ||
cache = ByteArray(4) | ||
iCache = inputStream.read(cache, 0, iCache) | ||
if (iCache < 0) | ||
throw InvalidFileException("INFO.fsplitinfo", 0x00000005) | ||
inputStream.close() | ||
return Fsplitinfo(maxFilenameCount, String(cache, StandardCharsets.UTF_8)) | ||
} |
3 changes: 3 additions & 0 deletions
3
src/io/github/teddyxlandlee/nios/filesplit/util/Fsplitinfo.kt
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,3 @@ | ||
package io.github.teddyxlandlee.nios.filesplit.util | ||
|
||
data class Fsplitinfo(val maxFileNameCount: Int, val filename: String) |