diff options
author | Edoardo La Greca | 2025-08-10 16:07:07 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-10 16:07:07 +0200 |
commit | 9cb11864e2bd698874ec35af8d75b18d9d18217f (patch) | |
tree | dff6fa88be143baf5a597034de8dd1c5b51069c9 | |
parent | bda07601a8b2dd9f016a3e5ac4a6e0ec7fa9a23c (diff) |
demote primary constructor to secondary in FilePermissions
-rw-r--r-- | src/main/kotlin/FilePermissions.kt | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/src/main/kotlin/FilePermissions.kt b/src/main/kotlin/FilePermissions.kt index 04561fe..dbb9dc4 100644 --- a/src/main/kotlin/FilePermissions.kt +++ b/src/main/kotlin/FilePermissions.kt @@ -1,12 +1,28 @@ /** * The permissions of a newly created file. - * - * @param userPerms The permissions for the file's owning user. - * @param groupPerms The permissions for the file's owning group. - * @param elsePerms The permissions for everyone else. - * @param isDirectory Is the file a directory? If not, it's a regular file. */ -class FilePermissions(val userPerms: Permissions, val groupPerms: Permissions, val elsePerms: Permissions, val isDirectory: Boolean) { +class FilePermissions { + + /** + * The permissions for the file's owning user. + */ + val userPerms: Permissions + + /** + * The permissions for the file's owning group. + */ + val groupPerms: Permissions + + /** + * The permissions for everyone else. + */ + val elsePerms: Permissions + + /** + * Is the file a directory? If not, it's a regular file. + */ + val isDirectory: Boolean + enum class Permissions(val bits: UByte) { READ(0x4u), WRITE(0x2u), @@ -18,6 +34,21 @@ class FilePermissions(val userPerms: Permissions, val groupPerms: Permissions, v } /** + * Constructor for file permissions with separate fields. + * + * @param userPerms The permissions for the file's owning user. + * @param groupPerms The permissions for the file's owning group. + * @param elsePerms The permissions for everyone else. + * @param isDirectory Is the file a directory? If not, it's a regular file. + */ + constructor(userPerms: Permissions, groupPerms: Permissions, elsePerms: Permissions, isDirectory: Boolean) { + this.userPerms = userPerms + this.groupPerms = groupPerms + this.elsePerms = elsePerms + this.isDirectory = isDirectory + } + + /** * Turn the permissions described by the [FilePermissions] fields into a permission integer (4 bytes). */ fun toPermissionInt(): UInt { |