summaryrefslogtreecommitdiff
path: root/src/main/kotlin/Stat.kt
blob: 4f0f625f7567020fa2f223c3843fbe289a779cdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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).
 */
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

    /**
     * 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
    }