From 09fb2b97be7d3d4e8e2a4df9494672d18b2ec29a Mon Sep 17 00:00:00 2001 From: inseo <i32kim@uwaterloo.ca> Date: Sun, 12 Feb 2023 17:26:34 -0500 Subject: [PATCH] File management non printing bug has been fixed --- console/src/main/kotlin/notes/multi/console/Console.kt | 1 + console/test/hello.txt | 1 - utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 console/test/hello.txt diff --git a/console/src/main/kotlin/notes/multi/console/Console.kt b/console/src/main/kotlin/notes/multi/console/Console.kt index d5b30e4..647d117 100644 --- a/console/src/main/kotlin/notes/multi/console/Console.kt +++ b/console/src/main/kotlin/notes/multi/console/Console.kt @@ -10,4 +10,5 @@ fun main() { val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt") f.writefile("hello world") println(f.openfile()) + f.deletefile() } diff --git a/console/test/hello.txt b/console/test/hello.txt deleted file mode 100644 index 95d09f2..0000000 --- a/console/test/hello.txt +++ /dev/null @@ -1 +0,0 @@ -hello world \ No newline at end of file diff --git a/utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt b/utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt index e4e934b..0f0e3bd 100644 --- a/utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt +++ b/utilities/src/main/kotlin/notes/multi/utilities/Filemanager.kt @@ -24,6 +24,7 @@ class Filemanager(private val dir: String, private val name: String) { // create and write to that file fun writefile(line:String) { filepath.writeText(line) + listfiles.add(filepath) } // opens and read the existing file @@ -37,6 +38,7 @@ class Filemanager(private val dir: String, private val name: String) { } fun deletefile():Boolean { + listfiles.remove(filepath) return filepath.delete() } -- GitLab