package eu.friedcutlet.yokan.services.files /** A picker-owned read grant. Only selected files are read; callers never inspect their parent. */ interface LocalMediaInput { val relativePath: String val sizeBytes: Long? /** Backpressure is mandatory; each chunk is at most [LOCAL_IMPORT_CHUNK_BYTES]. */ suspend fun readChunks(consume: suspend (ByteArray) -> Unit) } class LocalMediaSelection( val files: List, private val release: () -> Unit = {}, ) { fun close() = release() } internal const val LOCAL_IMPORT_CHUNK_BYTES = 64 * 1024 internal const val LOCAL_IMPORT_MAX_FILES = 10_000 internal val localImportExtensions = readableLocalFileExtensions + setOf("json", "nfo", "srt", "ass", "ssa", "vtt", "ttf", "otf", "key") /** Folder selections preserve their top-level name and relative structure. Never buffers media. */ expect suspend fun pickLocalMedia(directory: Boolean = false): LocalMediaSelection?