From 4d97ec858d796fab737dcb4b905861df2c5cb274 Mon Sep 17 00:00:00 2001 From: Deficuet Date: Thu, 9 May 2024 13:30:50 -0600 Subject: [PATCH] fix incorrect behavior when check file type --- .../github/deficuet/unitykt/internal/file/utils.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/io/github/deficuet/unitykt/internal/file/utils.kt b/src/main/kotlin/io/github/deficuet/unitykt/internal/file/utils.kt index 37624407..9fd7830d 100644 --- a/src/main/kotlin/io/github/deficuet/unitykt/internal/file/utils.kt +++ b/src/main/kotlin/io/github/deficuet/unitykt/internal/file/utils.kt @@ -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 @@ -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 }