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.swing.Swing
|
||||
import java.nio.file.Files
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class Watcher {
|
||||
|
@ -18,6 +19,12 @@ class Watcher {
|
|||
WATCHING = true
|
||||
while (WATCHING) {
|
||||
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
|
||||
|
||||
class WatcherManager {
|
||||
private val entries: List<WatcherEntry>
|
||||
|
||||
init {
|
||||
entries = arrayListOf()
|
||||
}
|
||||
private val entries: ArrayList<WatcherEntry> = arrayListOf()
|
||||
|
||||
fun addFile(file: File) {
|
||||
val watcherEntry = WatcherEntry(file, arrayListOf())
|
||||
entries.add(watcherEntry)
|
||||
Logger.info("Traking new file: ${file.name} (${file.absolutePath})")
|
||||
}
|
||||
|
||||
fun getEntries(): ArrayList<WatcherEntry> {
|
||||
return entries
|
||||
}
|
||||
}
|
Reference in a new issue