summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdoardo La Greca2025-08-07 19:04:10 +0200
committerEdoardo La Greca2025-08-07 19:04:47 +0200
commitb3bea2bea5c90435f0f1ed42b0cf82e453105c13 (patch)
tree86f7e83bc8baf132566c7046d307e0d3afbf4b2d
parentf7113c94abce7deec8bece794a3748cbee8a9a08 (diff)
add genFID to PathInfo
-rw-r--r--src/main/kotlin/PathInfo.kt15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/kotlin/PathInfo.kt b/src/main/kotlin/PathInfo.kt
index 4981662..c803e17 100644
--- a/src/main/kotlin/PathInfo.kt
+++ b/src/main/kotlin/PathInfo.kt
@@ -68,4 +68,19 @@ class PathInfo() {
fun getAllPaths(): Set<Path> {
return this.paths.toSet()
}
+
+ /**
+ * Generate a new FID which is not already in use.
+ *
+ * @return The new FID.
+ * @throws IllegalStateException if there is no available FID.
+ */
+ fun genFID(): UInt {
+ for (newFid in 0u..UInt.MAX_VALUE) {
+ if (findByFID(newFid) == null) {
+ return newFid
+ }
+ }
+ throw IllegalStateException()
+ }
} \ No newline at end of file