LibreTube/app/src/main/java/com/github/libretube/extensions/Path.kt
2023-03-17 09:17:33 +05:30

16 lines
359 B
Kotlin

package com.github.libretube.extensions
import android.net.Uri
import androidx.core.net.toUri
import java.nio.file.Path
import kotlin.io.path.exists
fun Path.toAndroidUriOrNull(): Uri? {
return if (exists()) toAndroidUri() else null
}
fun Path.toAndroidUri(): Uri {
@Suppress("NewApi") // The Path class is desugared.
return toFile().toUri()
}