'Possible values for fs.writefile options parameter especially what will be integer for read-only file
In fs.writeFile(file, data, options, callback) function, when it comes to options we can specify mode(integer)
I want to get to know what can be possible integers for different file modes
Solution 1:[1]
You can find the file modes available here.
You can create octals yourself as per documentation.
An easier method of constructing the mode is to use a sequence of three octal digits (e.g. 765). The left-most digit (7 in the example), specifies the permissions for the file owner. The middle digit (6 in the example), specifies permissions for the group. The right-most digit (5 in the example), specifies the permissions for others.
Read only should be 0o444
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shivam |


