From 7c2961a72d4dd2477e561e3009752c1cbd0a22e0 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Mon, 11 Aug 2025 19:30:07 +0200 Subject: add checkTypeBits --- src/main/kotlin/QID.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/QID.kt b/src/main/kotlin/QID.kt index ed5abbf..3e32523 100644 --- a/src/main/kotlin/QID.kt +++ b/src/main/kotlin/QID.kt @@ -66,19 +66,28 @@ class QID { this.path = InMessage.convInteger(rawPath, 0, rawPath.size).toLong().toULong() } + /** + * Check bit values in [type]. In case of multiple bits, the method returns true if at least one of them is 1. + * + * @param bits A byte whose bits set to 1 are checked. + */ + private fun checkTypeBits(bits: UByte): Boolean { + return this.type.and(bits) != 0u.toUByte() + } + private fun getIsDirectory(): Boolean { - return this.type.and(0x80.toUByte()) != 0u.toUByte() + return checkTypeBits(0x80u) } private fun getIsAppendOnly(): Boolean { - return this.type.and(0x40.toUByte()) != 0u.toUByte() + return checkTypeBits(0x40u) } private fun getIsExclusive(): Boolean { - return this.type.and(0x20.toUByte()) != 0u.toUByte() + return checkTypeBits(0x20u) } private fun getIsTemporary(): Boolean { - return this.type.and(0x04.toUByte()) != 0u.toUByte() + return checkTypeBits(0x04u) } } \ No newline at end of file -- cgit v1.2.3