49 lines
1.5 KiB
Markdown
49 lines
1.5 KiB
Markdown
# 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
|
|
|
|
```kotlin
|
|
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:
|
|
|
|
```kotlin
|
|
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:
|
|
|
|
```kotlin
|
|
@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.
|
|
|
|
## Publish
|
|
|
|
Publish locally with:
|
|
|
|
```shell
|
|
./gradlew publishToMavenLocal
|
|
```
|
|
|
|
Publish to Reposilite with:
|
|
|
|
```shell
|
|
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`.
|