pull/84/head
kunfei 5 years ago
parent 37c7a4fdad
commit 8ffa73f269
  1. 5
      app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt

@ -34,7 +34,7 @@ object AnalyzeTxtFile {
val toc = arrayListOf<BookChapter>() val toc = arrayListOf<BookChapter>()
//获取文件流 //获取文件流
val bookStream = RandomAccessFile(bookFile, "r") val bookStream = RandomAccessFile(bookFile, "r")
val rulePattern = getTocRule(bookStream, charset) val rulePattern = getTocRule(book, bookStream, charset)
//加载章节 //加载章节
val buffer = ByteArray(BUFFER_SIZE) val buffer = ByteArray(BUFFER_SIZE)
@ -205,7 +205,7 @@ object AnalyzeTxtFile {
return bookFile return bookFile
} }
private fun getTocRule(bookStream: RandomAccessFile, charset: Charset): Pattern? { private fun getTocRule(book: Book, bookStream: RandomAccessFile, charset: Charset): Pattern? {
val tocRules = getTocRules() val tocRules = getTocRules()
var rulePattern: Pattern? = null var rulePattern: Pattern? = null
//首先获取128k的数据 //首先获取128k的数据
@ -216,6 +216,7 @@ object AnalyzeTxtFile {
val pattern = Pattern.compile(tocRule.rule, Pattern.MULTILINE) val pattern = Pattern.compile(tocRule.rule, Pattern.MULTILINE)
val matcher = pattern.matcher(content) val matcher = pattern.matcher(content)
if (matcher.find()) { if (matcher.find()) {
book.tocUrl = tocRule.rule
rulePattern = pattern rulePattern = pattern
break break
} }

Loading…
Cancel
Save