Skip to content

saveourtool/okio-extras

Repository files navigation

okio-extras

Table of Contents
License: MIT
badge
GitHub release

A set of extensions to Okio.

See the project website for documentation and APIs.

Features

Among other useful multiplatform extensions, which are modelled after kotlin.io API available on the JVM, the library provides a way to convert a file system path to a file:// URI and vice versa:

// Will print "file:/C:/Windows/"
println("C:\\Windows".toPath().toFileUri())

// Will print "C:\Program Files"
println(Uri("file:///C:/Program%20Files").toLocalPath().pathString)

UNC paths are supported on Windows:

// Will print "\\127.0.0.1\C$\Windows"
println(Uri("file:////127.0.0.1/C$/Windows").toLocalPath().pathString)

// Will print "\\WSL$\Debian\etc\passwd"
println(Uri("file:////WSL$/Debian/etc/passwd").toLocalPath().pathString)

IPv6 addresses are parsed correctly:

// Will print "\\--1.ipv6-literal.net\C$\Windows"
println(Uri("file://[::1]/C$/Windows").toLocalPath().pathString)

Releases

The latest release is available from GitHub Packages.

For build.gradle.kts:

repositories {
    maven {
        name = "saveourtool/okio-extras"
        url = uri("https://maven.pkg.github.com/saveourtool/okio-extras")
        credentials {
            username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
            password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
        }
    }
}

For settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        maven {
            name = "saveourtool/okio-extras"
            url = uri("https://maven.pkg.github.com/saveourtool/okio-extras")
            credentials {
                username = providers.gradleProperty("gpr.user").orNull
                    ?: System.getenv("GITHUB_ACTOR")
                password = providers.gradleProperty("gpr.key").orNull
                    ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }
}

Then add the dependency as usual:

dependencies {
    implementation("com.saveourtool:okio-extras:1.1.1")
}