- Version: all
- Platform: Windows
- Subsystem: fs
Trying to open a hidden file on Windows in 'w' mode throws EPERM:
> fs.openSync('hidden.txt', 'w')
Error: EPERM: operation not permitted, open 'C:\hidden.txt'
at Object.fs.openSync (fs.js:651:18)
at repl:1:4
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:433:10)
at emitOne (events.js:120:20)
at REPLServer.emit (events.js:210:7)
at REPLServer.Interface._onLine (readline.js:278:10)
This matches the behavior of Microsoft C runtime library:
#include <cstdio>
#include <cerrno>
int main()
{
FILE* f = fopen("hidden.txt", "w");
if (f) {
puts("success");
} else if (errno == EACCES) {
perror("EACCES");
} else {
perror("something else");
}
}
Output if "hidden.txt" is hidden:
EACCES: Permission denied
And it matches the behavior of Python since it purportedly uses _wfopen under the hood:
>>> open("hidden.txt", "w")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'hidden.txt'
However, this behavior has caused at least two issues down the road:
So, my questions are:
- Does Node.js really have to match CRT's behavior here? Would anything break if it started allowing opening hidden files in 'w' mode?
- If we can't or don't want to "fix" this, do we want to document this behavior, or do we just say "does the same thing CRT does"?
Trying to open a hidden file on Windows in 'w' mode throws
EPERM:This matches the behavior of Microsoft C runtime library:
Output if "hidden.txt" is hidden:
And it matches the behavior of Python since it purportedly uses
_wfopenunder the hood:However, this behavior has caused at least two issues down the road:
So, my questions are: