Quellcode durchsuchen

修复低版本手机打开本地文件出错的bug

gedoor vor 4 Jahren
Ursprung
Commit
3e3dbe1636
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt

+ 5 - 1
app/src/main/java/io/legado/app/model/localBook/LocalBook.kt

@@ -35,7 +35,11 @@ object LocalBook {
         if (uri.isContentScheme()) {
             return appCtx.contentResolver.openInputStream(uri)!!
         }
-        return FileInputStream(File(uri.path!!))
+        val file = File(uri.path!!)
+        if (file.exists()) {
+            return FileInputStream(File(uri.path!!))
+        }
+        throw FileNotFoundException("${uri.path} 文件不存在")
     }
 
     @Throws(Exception::class)