diff options
Diffstat (limited to 'src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt')
-rw-r--r-- | src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt b/src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt new file mode 100644 index 0000000..9a869d4 --- /dev/null +++ b/src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt @@ -0,0 +1,13 @@ +package com.replaymod.gradle.remap.util + +import org.cadixdev.lorenz.MappingSet +import org.cadixdev.lorenz.io.MappingFormats +import java.nio.file.Path + +fun Path.readMappings(): MappingSet { + val name = fileName.toString() + val ext = name.substring(name.lastIndexOf(".") + 1) + val format = MappingFormats.REGISTRY.values().find { it.standardFileExtension.orElse(null) == ext } + ?: throw UnsupportedOperationException("Cannot find mapping format for $this") + return format.read(this) +} |