diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index 9d6777057..61693d8f6 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -4,6 +4,7 @@ import android.content.Context import android.net.Uri import io.legado.app.App import io.legado.app.data.entities.Book +import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.TxtTocRule import io.legado.app.utils.* import java.io.File @@ -28,13 +29,27 @@ object AnalyzeTxtFile { } } book.charset = EncodingDetect.getEncode(bookFile) - val tocRules = getTocRules() + val toc = arrayListOf() //获取文件流 val bookStream = RandomAccessFile(bookFile, "r") + val tocRule = getTocRule(bookStream) + } + private fun getTocRule(bookStream: RandomAccessFile): String? { + val tocRules = getTocRules() + var tocRule: String? = null + //首先获取128k的数据 + val buffer = ByteArray(10240) + val length = bookStream.read(buffer, 0, buffer.size) + for (str in tocRules) { + + } + return tocRule + } + private fun getTocRules(): List { val rules = App.db.txtTocRule().all if (rules.isEmpty()) {