Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.writeFile callback has no error when writing file failed #13868

Closed
apoliszk opened this issue Jun 22, 2017 · 6 comments
Closed

fs.writeFile callback has no error when writing file failed #13868

apoliszk opened this issue Jun 22, 2017 · 6 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform. wip Issues and PRs that are still a work in progress.

Comments

@apoliszk
Copy link

  • Version: v8.1.2
  • Platform: win10 64bit
var fs = require('fs');

fs.writeFile('test: abc.js', 'aaaa', function (err) {
    debugger;
});

The filename has a colon which is not allowed on win10.
The piece of code wrote a file named test which suppose to be test: abc.js, and there was no content.
The execution was failed, but there was no error. Parameter err is null.

@vkurchatkin vkurchatkin added windows Issues and PRs related to the Windows platform. fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. labels Jun 22, 2017
@XadillaX
Copy link
Contributor

@apoliszk how about v6 and v4?

@XadillaX
Copy link
Contributor

XadillaX commented Jun 22, 2017

It seems CreateFileW (Refer here) don't support :. I'll try to work for it.

@refack refack added the wip Issues and PRs that are still a work in progress. label Jun 22, 2017
@bzoz
Copy link
Contributor

bzoz commented Jun 27, 2017

This is a lesser known feature of Windows - alternative data streams. You can read more about them in this MSDN article.

The data is there:

D:\>node -e "require('fs').writeFile('testfile:abc', 'some data', console.log)"
null

D:\>dir /r testfile
 Volume in drive D is Staff
 Volume Serial Number is 565B-E08C

 Directory of D:\

27.06.2017  10:49                 0 testfile
                                  9 testfile:abc:$DATA
               1 File(s)              0 bytes
               0 Dir(s)  10 776 190 976 bytes free

D:\>more < testfile

D:\>more < testfile:abc
some data

@bzoz
Copy link
Contributor

bzoz commented Jun 27, 2017

Also, note that for other chars Node fails as expected:

D:\>node -e "require('fs').writeFile('testfile>abc', 'some data', console.log)"
{ Error: ENOENT: no such file or directory, open 'D:\testfile>abc'
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\testfile>abc' }

@apoliszk
Copy link
Author

Thanks everyone.
I got it.
It is how windows is designed, not a bug.

XadillaX added a commit to XadillaX/node that referenced this issue Jul 5, 2017
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)

Refs: nodejs#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
refack pushed a commit to refack/node that referenced this issue Jul 9, 2017
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: nodejs#13875
Refs: nodejs#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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
addaleax pushed a commit that referenced this issue Jul 11, 2017
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: #13875
Refs: #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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
addaleax pushed a commit that referenced this issue Jul 18, 2017
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: #13875
Refs: #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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Fishrock123 pushed a commit that referenced this issue Jul 19, 2017
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: #13875
Refs: #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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@bhadkiaftab
Copy link

This error will occure when mentioned directory is not present in that path.

MylesBorins pushed a commit that referenced this issue Aug 16, 2017
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: #13875
Refs: #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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MylesBorins pushed a commit that referenced this issue Sep 5, 2017
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: #13875
Refs: #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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

No branches or pull requests

6 participants