From 6c516e1e135430ed3a1f854aedc6a7af3c3d9fda Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Sat, 9 Aug 2025 21:15:55 +0200 Subject: implement clunk --- src/main/kotlin/Connection.kt | 13 +++++++++++-- src/main/kotlin/ProtocolTranslator.kt | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index d5330d7..c77a381 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -258,8 +258,17 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { return count.toInt().toUInt() } - override fun clunk(path: String) { - TODO("Not yet implemented") + override fun clunk(fid: UInt) { + val omsg = OutMessage(NinePMessageType.TCLUNK, this.tagGen.generate(), listOf("fid"), + mapOf( + "fid" to Pair(BigInteger(fid.toString()), 4u) + ), + emptyMap(), + emptyMap(), + this.maxSize + ) + omsg.write(this.tl) + val imsg = checkedInMessage(omsg.tag) } override fun remove(path: String) { diff --git a/src/main/kotlin/ProtocolTranslator.kt b/src/main/kotlin/ProtocolTranslator.kt index 8623737..cee72f4 100644 --- a/src/main/kotlin/ProtocolTranslator.kt +++ b/src/main/kotlin/ProtocolTranslator.kt @@ -128,9 +128,13 @@ interface ProtocolTranslator { fun write(fid: UInt, offset: ULong, count: UInt, data: Iterable): UInt /** - * Forget about an FID. + * Forget about a FID. + * + * @param fid The FID to forget. + * @throws except.InvalidMessageException if the received message is invalid. + * @throws except.RErrorException if the received message is an R-error message. */ - fun clunk(path: String) + fun clunk(fid: UInt) /** * Remove a file from a server. -- cgit v1.2.3