|
@@ -1,37 +1,28 @@
|
|
|
package tachiyomi.source.local.io
|
|
|
|
|
|
-import android.content.Context
|
|
|
-import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|
|
-import tachiyomi.core.i18n.stringResource
|
|
|
-import tachiyomi.i18n.MR
|
|
|
+import tachiyomi.core.provider.FolderProvider
|
|
|
import java.io.File
|
|
|
|
|
|
actual class LocalSourceFileSystem(
|
|
|
- private val context: Context,
|
|
|
+ private val folderProvider: FolderProvider,
|
|
|
) {
|
|
|
|
|
|
- private val baseFolderLocation = "${context.stringResource(MR.strings.app_name)}${File.separator}local"
|
|
|
-
|
|
|
- actual fun getBaseDirectories(): Sequence<File> {
|
|
|
- return DiskUtil.getExternalStorages(context)
|
|
|
- .map { File(it.absolutePath, baseFolderLocation) }
|
|
|
- .asSequence()
|
|
|
+ actual fun getBaseDirectory(): File {
|
|
|
+ return File(folderProvider.directory(), "local")
|
|
|
}
|
|
|
|
|
|
- actual fun getFilesInBaseDirectories(): Sequence<File> {
|
|
|
- return getBaseDirectories()
|
|
|
- // Get all the files inside all baseDir
|
|
|
- .flatMap { it.listFiles().orEmpty().toList() }
|
|
|
+ actual fun getFilesInBaseDirectory(): List<File> {
|
|
|
+ return getBaseDirectory().listFiles().orEmpty().toList()
|
|
|
}
|
|
|
|
|
|
actual fun getMangaDirectory(name: String): File? {
|
|
|
- return getFilesInBaseDirectories()
|
|
|
+ return getFilesInBaseDirectory()
|
|
|
// Get the first mangaDir or null
|
|
|
.firstOrNull { it.isDirectory && it.name == name }
|
|
|
}
|
|
|
|
|
|
- actual fun getFilesInMangaDirectory(name: String): Sequence<File> {
|
|
|
- return getFilesInBaseDirectories()
|
|
|
+ actual fun getFilesInMangaDirectory(name: String): List<File> {
|
|
|
+ return getFilesInBaseDirectory()
|
|
|
// Filter out ones that are not related to the manga and is not a directory
|
|
|
.filter { it.isDirectory && it.name == name }
|
|
|
// Get all the files inside the filtered folders
|