diff options
author | Edoardo La Greca | 2025-08-11 19:30:07 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-11 19:30:07 +0200 |
commit | 7c2961a72d4dd2477e561e3009752c1cbd0a22e0 (patch) | |
tree | d595b63e2e1e92e1c5a1434d332f0bd743816b2e | |
parent | fcaeb6e9e83a04c0a2a16353b6d2ebc6bd291a40 (diff) |
add checkTypeBits
-rw-r--r-- | src/main/kotlin/QID.kt | 17 |
1 files 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 |