Upgrade to OPENRNDR 0.4 snapshot
This commit is contained in:
29
orx-jvm/orx-olive/src/main/kotlin/Resources.kt
Normal file
29
orx-jvm/orx-olive/src/main/kotlin/Resources.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.openrndr.extra.olive
|
||||
|
||||
import java.io.File
|
||||
|
||||
class Resources(val filterOutExtensions: List<String> = listOf()) {
|
||||
private val watchedResources = mutableMapOf<File, Boolean>()
|
||||
|
||||
fun watch(src: File, watchFn: (file: File) -> Unit) {
|
||||
src.listFiles()!!.forEach {file ->
|
||||
if (file.isFile && !filterOutExtensions.contains(file.extension)) {
|
||||
watchedResources[file] = false
|
||||
|
||||
watchFn(file)
|
||||
} else if (file.isDirectory) {
|
||||
watch(file, watchFn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(file: File): Boolean? {
|
||||
return watchedResources[file]
|
||||
}
|
||||
|
||||
operator fun set(file: File, value: Boolean) {
|
||||
if (watchedResources.containsKey(file)) {
|
||||
watchedResources[file] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user