Created
October 29, 2017 20:42
-
-
Save pitaj/047faae18463835a8b7697e2964a341e to your computer and use it in GitHub Desktop.
Demonstrate different error codes being thrown depending on platform when attempting to write to a read-only file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment