diff options
Diffstat (limited to 'src/main/kotlin/FilePermissions.kt')
-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 { |