Tiny, fluent Kotlin DSL for working with byte counts using binary (IEC) and decimal units.
- Inline
StorageSizevalue type with arithmetic and comparisons. - Binary (
KiB,MiB, …) and decimal (KB,MB, …) extensions onInt/Long. - Converters for byte counts and
Pathsizes (toStorageSize()).
- Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}- Depend on your GitHub fork/tag:
dependencies {
implementation("com.github.No3x:kbytes:1.0.0")
}Replace 1.0.0 with the tag you want.
val size = 3.GB + 512.MB // arithmetic
println(size.bestDecimalUnit()) // Sized(value=3.512, unit=GB)
val fileSize = somePath.toStorageSize()
println(fileSize.inBytes())