summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdoardo La Greca2025-08-11 19:55:50 +0200
committerEdoardo La Greca2025-08-11 19:55:50 +0200
commit0c6c60897395982caa998953d10ec40b831951b5 (patch)
tree2985913f06d8de239f98b99fceeb2a119f88daf1
parent877090c8c5300a98cd20dc79d96848f74aeb4cad (diff)
turn Stat into a regular class
-rw-r--r--src/main/kotlin/Stat.kt100
1 files changed, 78 insertions, 22 deletions
diff --git a/src/main/kotlin/Stat.kt b/src/main/kotlin/Stat.kt
index 706036e..4f0f625 100644
--- a/src/main/kotlin/Stat.kt
+++ b/src/main/kotlin/Stat.kt
@@ -1,28 +1,84 @@
+import java.math.BigInteger
+
// TODO: add time conversion methods
/**
* File attributes. The `type` and `dev` attributes are ignored since they are for kernel use only. Time is measured in
* seconds, since the epoch (Jan 1 00:00 1970 GMT).
- *
- * @param fid The FID sent the T-stat message.
- * @param qid The QID of the file.
- * @param mode Permissions and flags.
- * @param atime Last acces time.
- * @param mtime Last modification time.
- * @param length The length of the file in bytes.
- * @param name The file name, which is `/` if the file is the root directory.
- * @param uid The owner's name.
- * @param gid The group's name.
- * @param muid The name of the user who last modified the file.
*/
-data class Stat(
- val fid: UInt,
- val qid: QID,
- val mode: FilePermissions,
- val atime: UInt,
- val mtime: UInt,
- val length: ULong,
- val name: String,
- val uid: String,
- val gid: String,
+class Stat {
+ /**
+ * The FID sent the T-stat message.
+ */
+ val fid: UInt
+
+ /**
+ * The QID of the file.
+ */
+ val qid: QID
+
+ /**
+ * Permissions and flags.
+ */
+ val mode: FilePermissions
+
+ /**
+ * Last acces time.
+ */
+ val atime: UInt
+
+ /**
+ * Last modification time.
+ */
+ val mtime: UInt
+
+ /**
+ * The length of the file in bytes.
+ */
+ val length: ULong
+
+ /**
+ * The file name, which is `/` if the file is the root directory.
+ */
+ val name: String
+
+ /**
+ * The owner's name.
+ */
+ val uid: String
+
+ /**
+ * The group's name.
+ */
+ val gid: String
+
+ /**
+ * The name of the user who last modified the file.
+ */
val muid: String
-) \ No newline at end of file
+
+ /**
+ * Make an instance of [Stat] from each of its fields.
+ *
+ * @param fid The FID sent the T-stat message.
+ * @param qid The QID of the file.
+ * @param mode Permissions and flags.
+ * @param atime Last acces time.
+ * @param mtime Last modification time.
+ * @param length The length of the file in bytes.
+ * @param name The file name, which is `/` if the file is the root directory.
+ * @param uid The owner's name.
+ * @param gid The group's name.
+ * @param muid The name of the user who last modified the file.
+ */
+ constructor(fid: UInt, qid: QID, mode: FilePermissions, atime: UInt, mtime: UInt, length: ULong, name: String, uid: String, gid: String, muid: String) {
+ this.fid = fid
+ this.qid = qid
+ this.mode = mode
+ this.atime = atime
+ this.mtime = mtime
+ this.length = length
+ this.name = name
+ this.uid = uid
+ this.gid = gid
+ this.muid = muid
+ }