Closed
Description
- Version: 8.8.1
- Platform: tested on these systems
Linux peter-XPS-15 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
- Windows 10 64bit (version 1709)
- Subsystem: fs
Attempting to write to a read-only file will result in:
- an
EACCES
error on Linux systems - an
EPERM
error on Windows systems
Is this expected behavior? If so, it should be documented as such. The only mention of EPERM
is with relation to hidden files.
You can reproduce this by executing the following snippet on machines of the two different platforms.
const fs = require('fs');
const path = require('path');
const code = '444';
const filename = '00000';
const content = 'abcdefghijklmnopqrstuvwxyz';
const filePath = path.join(__dirname, filename);
// set up a read-only file
fs.writeFileSync(filePath, content);
fs.chmodSync(filePath, '444');
fs.writeFile(filePath, content, function (err) {
throw err;
});
https://gist.github.com/pitaj/047faae18463835a8b7697e2964a341e