aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin/com/replaymod/gradle/remap/util/mappingExtensions.kt
blob: 9a869d497e7ccb9f84e9da9fe44bd3d254e19e61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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)
}