Skip to content

Repository files navigation

kotlinx-io-tar a multiplatform library tar reader/writter

What is it?

This repository is a kotlin multiplatform library to read and create a tar. It uses kotlinx-io for the I/O part. Really basic support for now.

Why use a tar format?

If you have immutable data that doesn't need to be partially accessed, that's the perfect format! Also a specificity of a tar is that if you add more data to it, you can redownload only the difference as the tar will keep the order.

Documentation

Read a tar

SystemFileSystem.source(Path("my.tar"))
    .buffered()
    .tar().use { tar ->
        var nextEntry: TarEntry? = null
        while (tar.nextEntry.also { nextEntry = it } != null) {
            if (nextEntry != null) {
                val headerInfo = nextEntry.header
                val fileDataSource = tar.currentFile()
            }
        }
    }

Write a tar

val folder = "/tmp"
SystemFileSystem.sink(Path("myNew.tar"))
    .buffered()
    .tar().use { tarSink ->
        listOf("file1.txt", "flie2.xml").forEach { fileName ->
            val path = Path("$folder/$fileName")
            if (SystemFileSystem.exists(path)) {
                tarSink.putNextEntry(TarEntry(path, fileName))
                tarSink.write(path)
            }
        }
    }

Maintenance

Do a release

About

We are pascap LTD a small startup, if you want to support us don't hesitate to try our app on the play store, we use that library in production with that application.

No llm has been used for that repository.

Resources

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages