Add mobile file access sources

This commit is contained in:
2026-07-03 00:24:25 +02:00
parent 3da576a94e
commit 3cdbf7e8f9
11 changed files with 272 additions and 29 deletions

View File

@@ -0,0 +1,24 @@
package com.vnidrop.app.core
import platform.Foundation.NSURL
import uniffi.vnidrop.SourceKind
internal actual suspend fun <T> withPlatformPathAccess(
kind: SourceKind,
value: String,
block: suspend () -> T,
): T {
if (kind != SourceKind.IOS_SECURITY_SCOPED_URL) {
return block()
}
val url = NSURL.URLWithString(value) ?: NSURL.fileURLWithPath(value)
val didStartAccess = url.startAccessingSecurityScopedResource()
return try {
block()
} finally {
if (didStartAccess) {
url.stopAccessingSecurityScopedResource()
}
}
}