From 6d396368b7bfb862672ce849b9e283e6af145ed3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Apr 2022 14:44:31 +0300 Subject: [PATCH] Fixe meta file name --- CHANGELOG.md | 1 + build.gradle.kts | 2 +- .../kotlin/space/kscience/dataforge/data/DataSet.kt | 3 ++- .../jvmMain/kotlin/space/kscience/dataforge/io/fileIO.kt | 8 +++++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d27c79b..52af8804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### Removed ### Fixed +- Meta file name in readMeta from directory ### Security diff --git a/build.gradle.kts b/build.gradle.kts index 78ca749b..977b44f8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "space.kscience" - version = "0.6.0-dev-1" + version = "0.6.0-dev-2" repositories{ mavenCentral() } diff --git a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt index d4ca9296..45e60bb4 100644 --- a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt +++ b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/DataSet.kt @@ -10,7 +10,8 @@ import space.kscience.dataforge.meta.set import space.kscience.dataforge.names.* import kotlin.reflect.KType -public interface DataSet { +public interface +DataSet { /** * The minimal common ancestor to all data in the node diff --git a/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/fileIO.kt b/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/fileIO.kt index f2c664d4..1f2d3041 100644 --- a/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/fileIO.kt +++ b/dataforge-io/src/jvmMain/kotlin/space/kscience/dataforge/io/fileIO.kt @@ -91,6 +91,10 @@ public fun EnvelopeFormat.readFile(path: Path): Envelope { public inline fun IOPlugin.resolveIOFormat(): IOFormat? = ioFormatFactories.find { it.type.isSupertypeOf(typeOf()) } as IOFormat? + +public val IOPlugin.Companion.META_FILE_NAME: String get() = "@meta" +public val IOPlugin.Companion.DATA_FILE_NAME: String get() = "@data" + /** * Read file containing meta using given [formatOverride] or file extension to infer meta type. * If [path] is a directory search for file starting with `meta` in it @@ -103,7 +107,7 @@ public fun IOPlugin.readMetaFile( if (!Files.exists(path)) error("Meta file $path does not exist") val actualPath: Path = if (Files.isDirectory(path)) { - Files.list(path).asSequence().find { it.fileName.startsWith("meta") } + Files.list(path).asSequence().find { it.fileName.startsWith(IOPlugin.META_FILE_NAME) } ?: error("The directory $path does not contain meta file") } else { path @@ -147,8 +151,6 @@ public fun IOPlugin.peekFileEnvelopeFormat(path: Path): EnvelopeFormat? { return peekBinaryEnvelopeFormat(binary) } -public val IOPlugin.Companion.META_FILE_NAME: String get() = "@meta" -public val IOPlugin.Companion.DATA_FILE_NAME: String get() = "@data" /** * Read and envelope from file if the file exists, return null if file does not exist.