@@ -28,6 +28,10 @@ import okio.internal.commonResolve
2828import okio.internal.commonToPath
2929import okio.internal.commonToString
3030import okio.internal.commonVolumeLetter
31+ import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
32+ import java.io.File
33+ import java.nio.file.Paths
34+ import java.nio.file.Path as NioPath
3135
3236@ExperimentalFileSystem
3337actual class Path internal actual constructor(
@@ -65,6 +69,11 @@ actual class Path internal actual constructor(
6569 @JvmName(" resolve" )
6670 actual operator fun div (child : Path ): Path = commonResolve(child)
6771
72+ fun toFile (): File = File (toString())
73+
74+ @IgnoreJRERequirement // Can only be invoked on platforms that have java.nio.file.
75+ fun toNioPath (): NioPath = Paths .get(toString())
76+
6877 actual override fun compareTo (other : Path ): Int = commonCompareTo(other)
6978
7079 actual override fun equals (other : Any? ): Boolean = commonEquals(other)
@@ -74,12 +83,24 @@ actual class Path internal actual constructor(
7483 actual override fun toString () = commonToString()
7584
7685 actual companion object {
77- actual val directorySeparator: String = DIRECTORY_SEPARATOR
86+ /* *
87+ * Either `/` (on UNIX-like systems including Android, iOS, and Linux) or `\` (on Windows
88+ * systems).
89+ */
90+ @JvmField
91+ actual val DIRECTORY_SEPARATOR : String = File .separator
7892
7993 @JvmName(" get" ) @JvmStatic
8094 actual fun String.toPath (): Path = commonToPath()
8195
8296 @JvmName(" get" ) @JvmStatic
8397 actual fun String.toPath (directorySeparator : String? ): Path = commonToPath(directorySeparator)
98+
99+ @JvmName(" get" ) @JvmStatic
100+ fun File.toOkioPath (): Path = toString().toPath()
101+
102+ @JvmName(" get" ) @JvmStatic
103+ @IgnoreJRERequirement // Can only be invoked on platforms that have java.nio.file.
104+ fun NioPath.toOkioPath (): Path = toString().toPath()
84105 }
85106}
0 commit comments