Skip to content

Commit

Permalink
fix: Use correct class loader to load resources
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Dec 4, 2023
1 parent f9a5dc6 commit 1d5f1f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/app/revanced/util/ResourceUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.w3c.dom.Node
import java.nio.file.Files
import java.nio.file.StandardCopyOption

private val classLoader = object {}.javaClass.classLoader

/**
* Recursively traverse the DOM tree starting from the given root node.
*
Expand Down Expand Up @@ -45,7 +47,6 @@ fun ResourceContext.mergeStrings(host: String) {
* @param resources The resources to copy.
*/
fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) {
val classLoader = javaClass.classLoader
val targetResourceDirectory = this["res"]

for (resourceGroup in resources) {
Expand Down Expand Up @@ -77,7 +78,7 @@ fun ResourceContext.iterateXmlNodeChildren(
targetTag: String,
callback: (node: Node) -> Unit
) =
xmlEditor[javaClass.classLoader.getResourceAsStream(resource)!!].use {
xmlEditor[classLoader.getResourceAsStream(resource)!!].use {
val stringsNode = it.file.getElementsByTagName(targetTag).item(0).childNodes
for (i in 1 until stringsNode.length - 1) callback(stringsNode.item(i))
}
Expand Down

0 comments on commit 1d5f1f8

Please sign in to comment.