diff --git a/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt index b14c93f..587351f 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt @@ -2,6 +2,7 @@ package app.revanced.patcher.patch +import java.nio.file.Path import kotlin.reflect.KProperty class NoSuchOptionException(val option: String) : Exception("No such option: $option") @@ -189,4 +190,19 @@ sealed class PatchOption( ) : ListOption( key, default, options, title, description, required, validator ) + + /** + * A [PatchOption] representing a [Path]. + * @see PatchOption + */ + class PathOption( + key: String, + default: T?, + title: String, + description: String, + required: Boolean = false, + validator: (T?) -> Boolean = { true } + ) : PatchOption( + key, default, title, description, required, validator + ) } \ No newline at end of file diff --git a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt index 6a31e62..7661032 100644 --- a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt +++ b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt @@ -32,6 +32,7 @@ import org.jf.dexlib2.immutable.reference.ImmutableFieldReference import org.jf.dexlib2.immutable.reference.ImmutableStringReference import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue import org.jf.dexlib2.util.Preconditions +import java.io.File @Patch @Name("example-bytecode-patch") @@ -177,5 +178,8 @@ class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) { PatchOption.IntListOption( "key4", 1, listOf(1, 2, 3), "title", "description" ), + PatchOption.PathOption( + "key5", File("test.txt").toPath(), "title", "description" + ), ) }