feat: move files
This commit is contained in:
parent
52e3b5d385
commit
a3eaf023c8
2 changed files with 13 additions and 5 deletions
|
@ -2,6 +2,7 @@ package xyz.atnrch.wrench.watcher
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.swing.Swing
|
import kotlinx.coroutines.swing.Swing
|
||||||
|
import java.nio.file.Files
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class Watcher {
|
class Watcher {
|
||||||
|
@ -18,6 +19,12 @@ class Watcher {
|
||||||
WATCHING = true
|
WATCHING = true
|
||||||
while (WATCHING) {
|
while (WATCHING) {
|
||||||
delay(TimeUnit.SECONDS.toMillis(5))
|
delay(TimeUnit.SECONDS.toMillis(5))
|
||||||
|
val manager = WatcherManager()
|
||||||
|
for (entry: WatcherEntry in manager.getEntries()) {
|
||||||
|
entry.map.forEach {
|
||||||
|
Files.copy(entry.file.toPath(), it.toAbsolutePath())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,15 @@ import xyz.atnrch.wrench.logger.Logger
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class WatcherManager {
|
class WatcherManager {
|
||||||
private val entries: List<WatcherEntry>
|
private val entries: ArrayList<WatcherEntry> = arrayListOf()
|
||||||
|
|
||||||
init {
|
|
||||||
entries = arrayListOf()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addFile(file: File) {
|
fun addFile(file: File) {
|
||||||
val watcherEntry = WatcherEntry(file, arrayListOf())
|
val watcherEntry = WatcherEntry(file, arrayListOf())
|
||||||
|
entries.add(watcherEntry)
|
||||||
Logger.info("Traking new file: ${file.name} (${file.absolutePath})")
|
Logger.info("Traking new file: ${file.name} (${file.absolutePath})")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getEntries(): ArrayList<WatcherEntry> {
|
||||||
|
return entries
|
||||||
|
}
|
||||||
}
|
}
|
Reference in a new issue