Skip to content

Commit

Permalink
fix incorrect behavior when check file type
Browse files Browse the repository at this point in the history
  • Loading branch information
Deficuet authored and Deficuet committed May 9, 2024
1 parent 4d892a7 commit 4d97ec8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/kotlin/io/github/deficuet/unitykt/internal/file/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ import io.github.deficuet.unitykt.util.runThenReset
internal fun readerFileType(reader: EndianBinaryReader): FileType {
if (reader.length < 20) return FileType.RESOURCE
when (reader.runThenReset { readNullString(20) }) {
"UnityWeb", "UnityRaw", "UnityArchive", "UnityFS" -> return FileType.BUNDLE
"UnityWebData1.0" -> return FileType.WEB
"UnityWeb", "UnityRaw", "UnityArchive", "UnityFS",
"\u00FA\u00FA\u00FA\u00FA\u00FA\u00FA\u00FA\u00FA" -> {
return FileType.BUNDLE
}
"UnityWebData1.0" -> {
return FileType.WEB
}
else -> {
if (reader.length < 128) {
return FileType.RESOURCE
}
var magic = reader.runThenReset { read(2) }
if (CompressUtils.GZIP_MAGIC.contentEquals(magic)) {
return FileType.GZIP
Expand All @@ -33,7 +41,7 @@ internal fun isSerializedFile(reader: EndianBinaryReader) = reader.runThenReset
val mVersion = readUInt32()
var mDataOffset = readUInt32().toLong()
skip(4) //m_Endian(1), m_Reserved(3)
if (mVersion > 22u) {
if (mVersion >= 22u) {
if (length < 48) {
return@runThenReset false
}
Expand Down

0 comments on commit 4d97ec8

Please sign in to comment.