bskjon 77b56c0126
CI / test (push) Canceled after 0s
RealPath
2026-10-20 00:06:45 +02:00
CI
2026-10-11 20:04:54 +02:00
2026-10-11 19:56:26 +02:00
2026-10-20 00:06:45 +02:00
2026-10-11 19:57:03 +02:00
2026-10-20 00:06:45 +02:00
2026-10-11 19:56:26 +02:00
2026-10-11 19:56:26 +02:00
2026-10-11 19:56:26 +02:00
2026-10-20 00:06:45 +02:00
2026-10-11 19:56:26 +02:00

IFile

A small Kotlin/JVM library that puts file operations behind the IFile interface. UseFile is the real filesystem implementation. FakeFile is included as an alternate IFile implementation for tests that want to override the real filesystem without touching disk.

Use

dependencies {
    implementation("no.iktdev.library:files:1.0.0")
}

Add the Reposilite releases repository to the consuming project's dependency repositories. Use the snapshots repository when consuming a -SNAPSHOT version.

Hashing is part of IFile; both helpers return the included FileHash type, so consumers do not need a separate hashing dependency or imports:

val sha256: FileHash = IFile("video.mkv").toSha256()
val xxHash: FileHash = IFile("video.mkv").toXxHash()

Tests can set the existing factory to use the fake implementation:

@BeforeEach
fun setUp() {
    FakeFile.wipe()
    IFile.factory = { path -> FakeFile(path) }
}

FakeFile is intentionally a test implementation, not a full emulation of every platform filesystem behavior. toJavaFile() is unsupported by the fake.

IFile.normalized() collapses . and .. path segments without following symbolic links. IFile.realPath() follows symbolic links and requires the target to exist. To check that a referenced file stays under a root directory, compare canonical Path values:

val root = contentFolder.realPath()
val candidate = contentFolder.resolve("media/video.mkv").realPath()
require(candidate.startsWith(root))

FakeFile.symbolicLinkTo() can model links in tests; realPath() resolves those links against the fake file registry.

Publish

Publish locally with:

./gradlew publishToMavenLocal

Publish to Reposilite with:

REPOSILITE_USERNAME=... REPOSILITE_PASSWORD=... ./gradlew publish

Set releaseVersion or RELEASE_VERSION for a release version. The default is 1.0.0-SNAPSHOT; repository URLs can be overridden with REPOSILITE_SNAPSHOT_URL and REPOSILITE_RELEASE_URL.

S
Description
No description provided
Readme
113 KiB
0 Stars 1 Watchers 0 Forks
Realpath
Latest
2026-10-20 00:17:54 +02:00
Languages
Kotlin 100%