package net.taehui.twilight.system import net.taehui.twilight.Logger import net.taehui.twilight.TwilightComponent import net.taehui.twilight.Utility import java.io.IOException import java.nio.file.Files import java.nio.file.Path import java.util.concurrent.ConcurrentHashMap object NoteFilesSystem : Logger { private val noteFiles = ConcurrentHashMap<String, Path>() fun loadNoteFiles() { try { noteFiles.clear() Files.list(TwilightComponent.NOTE_ENTRY_PATH).use { noteFilePaths -> noteFilePaths.forEach { noteFilePath -> noteFiles["${noteFilePath.fileName}:0"] = noteFilePath } } logInfo("Loaded Note Files") } catch (e: IOException) { logFault(e) } } val noteFile: Map.Entry<String, Path>? get() = Utility.getSaltedItem(ArrayList<Map.Entry<String, Path>?>(noteFiles.entries), null) fun getNoteFile(noteID: String): Path? { return noteFiles[noteID] } fun hasNoteFile(noteID: String): Boolean { return noteFiles.containsKey(noteID) } }