LibreTube/app/src/main/java/com/github/libretube/extensions/Path.kt

12 lines
293 B
Kotlin
Raw Normal View History

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.toAndroidUri(): Uri? {
@Suppress("NewApi") // The Path class is desugared.
return if (exists()) toFile().toUri() else null
}