last commit

This commit is contained in:
2023-11-27 07:07:37 +03:00
parent 23286dd061
commit 0e195b0aee
26 changed files with 324 additions and 63 deletions
@@ -0,0 +1,26 @@
package com.megboyzz.devmenu.data.repositories
class MyClass {
fun main(){
val input = readln().split(",").associate {
val s = it.trim().split(" ")
s[0] to s[1].toInt()
}
var sum = 0
readln().split(" ").forEach {
val s = input[it] ?: 0
sum += s
}
println(sum)
}
}
@@ -17,15 +17,13 @@ abstract class BaseObserver(source: String) : FileObserver(source) {
@OptIn(ExperimentalStdlibApi::class)
final override fun onEvent(event: Int, path: String?) {
if(eventQueue.size < 3) eventQueue.add(event)
val e = FileEvent.entries.find { it.value == event }
val fileEvent = e ?: FileEvent.UNKNOWN
Log.i("BaseObserver", "event code = ${event.toHexString()}, FileEvent is $fileEvent")
if(hasLastThreeEvents()) onEvent(fileEvent, path)
onEvent(fileEvent, path)
}
private fun hasLastThreeEvents() = runCatching {
@@ -38,7 +36,9 @@ abstract class BaseObserver(source: String) : FileObserver(source) {
this.list { dir, _ -> Regex(regex).matches(dir.absolutePath) }?.asList() ?: listOf()
protected infix fun File.copyToThe(destination: File) = this.copyTo(destination, overwrite = true)
protected infix fun File.copyToThe(destination: File){
this.copyTo(destination, overwrite = true)
}
protected fun zipAll(outputFolder: String, filesToCompress: List<String>) {
if(filesToCompress.isEmpty()){
@@ -15,10 +15,10 @@ class SaveFileObserver(
private val checkList = listOf(
FileEvent.CLOSE_WRITE,
FileEvent.MODIFY,
FileEvent.DELETE,
//FileEvent.DELETE,
FileEvent.CREATE,
FileEvent.ACCESS,
FileEvent.OPEN,
//FileEvent.ACCESS,
//FileEvent.OPEN,
FileEvent.CLOSE_NOWRITE
)
init {