feat: Publicize resource utility functions
This commit adds the functions to the public API
This commit is contained in:
parent
47eac14f03
commit
20aff26784
|
@ -8,14 +8,15 @@ import org.w3c.dom.Node
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
|
||||||
internal object ResourceUtils {
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
object ResourceUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge strings. This manages [StringResource]s automatically.
|
* Merge strings. This manages [StringResource]s automatically.
|
||||||
*
|
*
|
||||||
* @param host The hosting xml resource. Needs to be a valid strings.xml resource.
|
* @param host The hosting xml resource. Needs to be a valid strings.xml resource.
|
||||||
*/
|
*/
|
||||||
internal fun ResourceContext.mergeStrings(host: String) {
|
fun ResourceContext.mergeStrings(host: String) {
|
||||||
this.iterateXmlNodeChildren(host, "resources") {
|
this.iterateXmlNodeChildren(host, "resources") {
|
||||||
// TODO: figure out why this is needed
|
// TODO: figure out why this is needed
|
||||||
if (!it.hasAttributes()) return@iterateXmlNodeChildren
|
if (!it.hasAttributes()) return@iterateXmlNodeChildren
|
||||||
|
@ -32,10 +33,11 @@ internal object ResourceUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy resources from the current class loader to the resource directory.
|
* Copy resources from the current class loader to the resource directory.
|
||||||
|
*
|
||||||
* @param sourceResourceDirectory The source resource directory name.
|
* @param sourceResourceDirectory The source resource directory name.
|
||||||
* @param resources The resources to copy.
|
* @param resources The resources to copy.
|
||||||
*/
|
*/
|
||||||
internal fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) {
|
fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) {
|
||||||
val classLoader = ResourceUtils.javaClass.classLoader
|
val classLoader = ResourceUtils.javaClass.classLoader
|
||||||
val targetResourceDirectory = this["res"]
|
val targetResourceDirectory = this["res"]
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ internal object ResourceUtils {
|
||||||
* @param resourceDirectoryName The name of the directory of the resource.
|
* @param resourceDirectoryName The name of the directory of the resource.
|
||||||
* @param resources A list of resource names.
|
* @param resources A list of resource names.
|
||||||
*/
|
*/
|
||||||
internal class ResourceGroup(val resourceDirectoryName: String, vararg val resources: String)
|
class ResourceGroup(val resourceDirectoryName: String, vararg val resources: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate through the children of a node by its tag.
|
* Iterate through the children of a node by its tag.
|
||||||
|
@ -63,7 +65,7 @@ internal object ResourceUtils {
|
||||||
* @param targetTag The target xml node.
|
* @param targetTag The target xml node.
|
||||||
* @param callback The callback to call when iterating over the nodes.
|
* @param callback The callback to call when iterating over the nodes.
|
||||||
*/
|
*/
|
||||||
internal fun ResourceContext.iterateXmlNodeChildren(
|
fun ResourceContext.iterateXmlNodeChildren(
|
||||||
resource: String,
|
resource: String,
|
||||||
targetTag: String,
|
targetTag: String,
|
||||||
callback: (node: Node) -> Unit
|
callback: (node: Node) -> Unit
|
||||||
|
|
Loading…
Reference in a new issue