Giter Club home page Giter Club logo

niok's Introduction

Download Apache license Build Status Ubuntu Build Status Windows SonarCloud Status

Niok - java.nio.file for Kotlin

Niok provides a Kotlin idiomatic API for java.nio.file (the package for non-blocking I/O file operations). We believe that using Files decreases readability => extension functions to the rescue 😏

Next to providing delegations to Files it also delegates to Kotlin's built-in extension functions for File and provides additional functions.

Installation

Niok is published to maven central. Following an example how to use it

repositories { mavenCentral() }
dependencies {
    implementation("ch.tutteli.niok:niok:1.5.0")
}

Documentation

Visit https://robstoll.github.io/niok/kdoc.

Contribute

You found a bug, a delegation to Files is missing or there is something else you would like to improve? Please open an issue, contributions are more than welcome 👍

License

Niok is licensed under Apache 2.0.

niok's People

Contributors

dependabot-preview[bot] avatar jgleitz avatar mx0c avatar renovate-bot avatar renovate[bot] avatar robstoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

niok's Issues

Compatibility to Java 9

This library does not seem to be compatible to Java 9, (see https://travis-ci.org/robstoll/atrium/builds/575927779)

The error message is:

error: cannot access module-info

  bad class file: /home/travis/.gradle/caches/modules-2/files-2.1/ch.tutteli.niok/niok/0.3.0/eecfeb6c40253092a279e92c9618ddde052bb8b3/niok-0.3.0.jar(/module-info.class)

    class file has wrong version 55.0, should be 53.0

    Please remove or make sure it appears in the correct subdirectory of the classpath.

It seems like the target version should be set to at least Java 9 when compiling, but I am not sure about that.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/build-ubuntu.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3.4.2
.github/workflows/build-windows.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3.4.2
.github/workflows/validate-gradle-wrapper.yml
  • actions/checkout v4
  • gradle/wrapper-validation-action v3
gradle
settings.gradle.kts
build.gradle.kts
  • org.jetbrains.kotlin.jvm 2.0.0
  • org.jetbrains.dokka 1.9.20
  • ch.tutteli.gradle.plugins.dokka 5.0.1
  • ch.tutteli.gradle.plugins.kotlin.module.info 5.0.1
  • ch.tutteli.gradle.plugins.publish 5.0.1
  • ch.tutteli.gradle.plugins.spek 5.0.1
  • io.gitlab.arturbosch.detekt 1.23.6
  • io.github.gradle-nexus.publish-plugin 2.0.0
  • ch.tutteli.atrium:atrium-fluent 1.2.0
  • ch.tutteli.spek:tutteli-spek-extensions 1.2.1
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.8

  • Check this box to trigger a request for Renovate to run again on this repository

Feature request: create file if not exists

While using your library to work with java.nio.file.Path instances I found myself missing a function to "just make sure a file exists".
With plain Java, the next best fix would be to create some helper class that handles the problem in a generic manner.
But with Kotlin, this can be an extension function 😄

My proposal is the addition of the following function to this library:

inline fun Path.createFileIfNotExists(vararg fileAttributes: FileAttribute<*>): Path =
    apply { try { createFile(fileAttributes) } catch (ignored: FileAlreadyExistsException) {} }

The longer (more readable form is the following:

inline fun Path.createFileIfNotExists(vararg fileAttributes: FileAttribute<*>): Path =
    this.also { path ->
        try {
            path.createFile(fileAttributes)
        } catch (ignored: FileAlreadyExistsException) {}
    }

The implementation uses another extension function provided by your library: Path.createFile().
It is of course possible to delegate directly to the java.nio.file.Files API which would change the semantics a bit and save an intermediate method call.

Also, the above proof of concept code is untested. Maybe inline functions have constraints that require a non-inline solution for this functionality.

I can provide a merge request if you are interested in this functionality.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.