File Permissions
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.
Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx". The first character is 'd', '-', or 'l' (directory, file, or link), followed by three sets of "rwx" values, indicating "read, write, execute" permissions. The first set is the user's rights, the middle set the group's rights, and the third everyone else's rights to that object.
Permission denied for any of these rights is represented by a '-' in place of the 'r', 'w', or 'x'. For example, a sample directory permission string would be "drwxr--r--", indicating full directory rights for the user, but "read-only" rights for the group member and all others.
Each "rwx" combination can also be represented by an octal value (0-7) with the most significant bit representing read permission, the next most significant bit representing write permission, and the least significant bit representing execute permission.
Challenge
Given a four-character code string made up of a character: 'D', 'F', or 'L', followed by a three-digit octal integer value, like 664, output the resulting 10 character string that represents the permission value indicated.
Input
Your program or function may either read the input from standard in (four characters will be entered, optionally followed by a newline) or be passed the input as an argument.
Your program may accept uppercase or lowercase inputs but must be consistent (either all inputs are uppercase or all inputs are lowercase).
Output
Your program must print the resulting ten-character string that represents the permission value indicated in the exact format specified above. Tailing white space is allowed.
Test Cases
In: F664
Out: -rw-rw-r--
In: D775
Out: drwxrwxr-x
In: L334
Out: l-wx-wxr--
In: F530
Out: -r-x-wx---
In: D127
Out: d--x-w-rwx
Scoring and Rules
- Standard loop-holes are forbidden.
- Standard rules apply.
- Please provide a link to test your code as well as an explanation.
- This is code-golf, so the shortest answer in bytes wins!