LocalMediaSelection.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/services/files/LocalMediaSelection.kt
1package eu.friedcutlet.yokan.services.files23/** A picker-owned read grant. Only selected files are read; callers never inspect their parent. */4interface LocalMediaInput {5 val relativePath: String6 val sizeBytes: Long?7 /** Backpressure is mandatory; each chunk is at most [LOCAL_IMPORT_CHUNK_BYTES]. */8 suspend fun readChunks(consume: suspend (ByteArray) -> Unit)9}1011class LocalMediaSelection(12 val files: List<LocalMediaInput>,13 private val release: () -> Unit = {},14) {15 fun close() = release()16}1718internal const val LOCAL_IMPORT_CHUNK_BYTES = 64 * 102419internal const val LOCAL_IMPORT_MAX_FILES = 10_00020internal val localImportExtensions = readableLocalFileExtensions +21 setOf("json", "nfo", "srt", "ass", "ssa", "vtt", "ttf", "otf", "key")2223/** Folder selections preserve their top-level name and relative structure. Never buffers media. */24expect suspend fun pickLocalMedia(directory: Boolean = false): LocalMediaSelection?25