From 2b8ba6f97659c5f2761221876069190f1f792e82 Mon Sep 17 00:00:00 2001 From: Arkadiy <83061703+MEFRREEX@users.noreply.github.com> Date: Wed, 10 May 2023 16:07:58 +0300 Subject: [PATCH] Update Config.kt --- .../com/mefrreex/vkbot/config/Config.kt | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/main/kotlin/com/mefrreex/vkbot/config/Config.kt b/src/main/kotlin/com/mefrreex/vkbot/config/Config.kt index c499056..5fd45d7 100644 --- a/src/main/kotlin/com/mefrreex/vkbot/config/Config.kt +++ b/src/main/kotlin/com/mefrreex/vkbot/config/Config.kt @@ -53,43 +53,11 @@ class Config(private val file: File) { } fun set(key: String, value: Any) { - val keys = key.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() - var current = config - for (i in 0 until keys.size - 1) { - val next = current!![keys[i]] as MutableMap? - if (next == null) { - val newMap = mutableMapOf() - current[keys[i]] = newMap - current = newMap - } else { - current = next - } - } - current!![keys[keys.size - 1]] = value + // TODO } fun save() { - val content = yaml!!.dump(config) - val lines = mutableListOf() - - // Считываем старое содержимое файла - if (file.exists()) { - file.forEachLine { line -> - lines.add(line) - } - } - - // Обновляем содержимое файла - val writer = file.bufferedWriter() - for (line in lines) { - if (line.trim().startsWith("#")) { - writer.write(line) - writer.newLine() - } - } - writer.write(content) - writer.flush() - writer.close() + // TODO } }