diff options
Diffstat (limited to 'src/main/kotlin/Connection.kt')
-rw-r--r-- | src/main/kotlin/Connection.kt | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index 6630567..1aeb4b1 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -2,8 +2,10 @@ import except.MsizeValueTooBigException import except.RErrorException import except.UnaccessibleFileException import except.UnknownVersionException +import java.io.File import java.io.IOException import java.math.BigInteger +import kotlin.io.path.Path /** * This class represents a 9P connection. It provides a practical implementation with networking to the 9P methods @@ -182,8 +184,25 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { this.pathInfo.addPath(PathInfo.Path(wname, newfid, qids.last())) } - override fun open(path: String) { - TODO("Not yet implemented") + override fun open(fid: UInt, mode: FileMode): Pair<QID, UInt> { + val omsg = OutMessage(NinePMessageType.TOPEN, this.tagGen.generate(), listOf("fid", "mode"), + mapOf( + "fid" to BigInteger(fid.toString()), + "mode" to BigInteger(mode.toModeByte().toString()) + ), + emptyMap(), + emptyMap(), + this.maxSize + ) + omsg.write(this.tl) + val imsg = checkedInMessage(omsg.tag) + imsg.applySchema(listOf( + InMessage.Field("qid", InMessage.Field.Type.RAW, 13u), + InMessage.Field("iounit", InMessage.Field.Type.INTEGER, 4u) + )) + val qid = QID(imsg.fieldsRaw["qid"]!!.toList()) + val iounit = imsg.fieldsInt["iounit"]!!.toInt().toUInt() + return Pair(qid, iounit) } override fun create(path: String) { |