From c307f03b2b30701230c354e098b31d87ed1baea4 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Tue, 4 Jul 2017 06:53:27 -0400 Subject: [PATCH] doc,test: fs - reserved characters under win32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explain the behavior of `fs.open()` under win32 that file path contains some characters and add some test cases for them. < (less than) > (greater than) : (colon) " (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? (question mark) * (asterisk) PR-URL: https://github.com/nodejs/node/pull/13875 Refs: https://github.com/nodejs/node/issues/13868 Refs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx Refs: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Bartosz Sosnowski Reviewed-By: Roman Reiss Reviewed-By: Tobias Nießen --- doc/api/fs.md | 10 +++++ .../test-fs-write-file-invalid-path.js | 45 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/parallel/test-fs-write-file-invalid-path.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 73dcf213e3fe43..3b7cdf33d77fd5 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1268,6 +1268,14 @@ fs.open('', 'a+', (err, fd) => { }); ``` +Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented +by [Naming Files, Paths, and Namespaces][]. Under NTFS, if the filename contains +a colon, Node.js will open a file system stream, as described by +[this MSDN page][MSDN-Using-Streams]. + +Functions based on `fs.open()` exhibit this behavior as well. eg. +`fs.writeFile()`, `fs.readFile()`, etc. + ## fs.openSync(path, flags[, mode])