IndustrialI
Denoโ€ข3y agoโ€ข
4 replies
Industrial

File Permissions on Deno.FileInfo

Hello. As a programming exercise I'm trying to convert a Decimal number into Octal and that Octal representation into a Unix File Permission representation (drwx-).

* I have a directory with the number 16877 -> 40755
* I have a file with the number 33188 -> 100644

Questions:

* Why does the first Octal number have 5 digits and the second one 6?
* I understand the meaning of the last 3 digits, but I don't understand the meaning of the 40 and the 100. Should I interpret the number from right to left?


According to ChatGPT:

The leftmost digit represents the file type. It can have various values depending on the file type, such as:

0: Regular file
1: FIFO (named pipe)
2: Directory
3: Symbolic link
4: Socket
5: Block device
6: Character device

If that's true why is my directory giving me a mode of 4 i.e. Socket and not 2 (Directory)?
Was this page helpful?