From 9cb11864e2bd698874ec35af8d75b18d9d18217f Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Sun, 10 Aug 2025 16:07:07 +0200 Subject: demote primary constructor to secondary in FilePermissions --- src/main/kotlin/FilePermissions.kt | 43 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'src/main/kotlin') 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), @@ -17,6 +33,21 @@ class FilePermissions(val userPerms: Permissions, val groupPerms: Permissions, v READ_WRITE_EXECUTE(READ.bits.or(WRITE.bits.or(EXECUTE.bits))) } + /** + * 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). */ -- cgit v1.2.3