SNRK-49: Made fields private

This commit is contained in:
Anton Belyi 2023-04-17 18:14:47 +03:00
parent 7b946c004f
commit 0dad4cd923

View File

@ -6,14 +6,14 @@ import space.kscience.snark.storage.FileWriter
import java.io.File import java.io.File
import java.nio.file.Path import java.nio.file.Path
public class LocalFile(val path: String): FileReader, FileWriter{ public class LocalFile(private val path: String) : FileReader, FileWriter {
override fun close() {} override fun close() {}
override suspend fun readAll(): ByteArray = File(this.path).readBytes() override suspend fun readAll(): ByteArray = File(this.path).readBytes()
override suspend fun write(bytes: ByteArray) = File(this.path).writeBytes(bytes) override suspend fun write(bytes: ByteArray) = File(this.path).writeBytes(bytes)
} }
public class LocalDirectory(val path: String): Directory { public class LocalDirectory(private val path: String) : Directory {
override fun close() {} override fun close() {}
override suspend fun get(filename: String): FileReader = LocalFile("${this.path}/$filename") override suspend fun get(filename: String): FileReader = LocalFile("${this.path}/$filename")
@ -22,6 +22,7 @@ public class LocalDirectory(val path: String): Directory {
throw UnsupportedOperationException("File already exists") throw UnsupportedOperationException("File already exists")
} }
} }
override suspend fun put(filename: String): FileWriter = LocalFile("${this.path}/$filename") override suspend fun put(filename: String): FileWriter = LocalFile("${this.path}/$filename")
override suspend fun getSubdir(dirpath: Path): Directory = LocalDirectory("${this.path}/$dirpath") override suspend fun getSubdir(dirpath: Path): Directory = LocalDirectory("${this.path}/$dirpath")