-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Test & document numeric flags to fs.open on unix #3641
Conversation
var openPath = path.join(common.tmpDir, 'file-should-not-exist'); | ||
|
||
// A simple case: O_WRONLY without O_CREAT shall fail with ENOENT | ||
var exceptionCaught = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assert.throws
instead
12b5803
to
053513f
Compare
@@ -340,6 +340,12 @@ The file is created if it does not exist. | |||
|
|||
* `'ax+'` - Like `'a+'` but fails if `path` exists. | |||
|
|||
On POSIX platforms `flags` can also be a number as documented by open(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just POSIX, it works on Windows too. Not all flags from require('constants')
are available but the common ones are.
053513f
to
9306682
Compare
@@ -350,6 +350,10 @@ created. On POSIX systems, `path` is considered to exist even if it is a symlink | |||
to a non-existent file. The exclusive flag may or may not work with network file | |||
systems. | |||
|
|||
`flags` can also be a number as documented by open(2); commonly used constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all users know what open(2)
means. Would be nice if this was linkified to some docs on it or even better the numbers being documented here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there are many (2) notations in this file; do you want to linkify every one? I suppose that should be another PR anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I can do it in another PR.
9306682
to
2abbf90
Compare
@@ -832,6 +836,8 @@ start at 0. The `encoding` can be any one of those accepted by [Buffer][]. | |||
|
|||
If `fd` is specified, `ReadStream` will ignore the `path` argument and will use | |||
the specified file descriptor. This means that no `open` event will be emitted. | |||
Note that `fd` should be blocking; non-blocking `fd`s could be passed to | |||
`net.Socket`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd write this as "should be opened in blocking mode".
Also, s/could/should/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fcntl
can set blocking mode after open, so imo "opened in blocking mode" may be inaccurate.
Okay will s/could/should/, not being a native speaker I have to trust you :)
Left some comments. @XeCycle GH doesn't send notifications for new or changed commits, better leave a comment or it won't get noticed until someone goes through the list of open pull requests (like I'm currently doing.) |
2abbf90
to
4284cd1
Compare
@bnoordhuis sorry am not aware of that, commenting this time. Rebased to latest master, and did s/could/should/. |
LGTM with a question. CI: https://ci.nodejs.org/job/node-test-pull-request/701/ |
@XeCycle ... this LGTM but can I ask you to please rebase and update? |
@jasnell will do that in 48hr. Now out on a vacation. |
4f6cb6f
to
4c90d94
Compare
@bnoordhuis @jasnell rebased, and reworded translation on windows to say "where applicable". Please check if these still LGTY. |
LGTM (with a comment) |
`flags` can also be a number as documented by open(2); commonly used constants | ||
are available from `require('constants')`. On Windows, flags are translated to | ||
their equivalent ones where acceptable. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this last sentence is a rather unclear. I'd recommend including a bit more detail about what is translated to what...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah seems a typo there, I wanted to say "where applicable". Yes, it is unclear; but details imo should go to libuv docs, but no one is taking on that. What about adding a few examples, "e.g. O_EXCL to xxx, O_RDWR to xxx..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples would be great, I think.
4c90d94
to
62d3163
Compare
Added a few examples to flags translation. |
This clarifies that fs.createReadStream and fs.createWriteStream, when passed a fd, expects the fd to be blocking, and suggests net.Socket as an alternative. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This clarifies that fs.createReadStream and fs.createWriteStream, when passed a fd, expects the fd to be blocking, and suggests net.Socket as an alternative. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This clarifies that fs.createReadStream and fs.createWriteStream, when passed a fd, expects the fd to be blocking, and suggests net.Socket as an alternative. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This clarifies that fs.createReadStream and fs.createWriteStream, when passed a fd, expects the fd to be blocking, and suggests net.Socket as an alternative. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This clarifies that fs.createReadStream and fs.createWriteStream, when passed a fd, expects the fd to be blocking, and suggests net.Socket as an alternative. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
This has been supperted for long but never tested nor documented. PR-URL: #3641 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
For #3628.
Do we prefer two commits here or one? Also, shall we backport the doc commit to older versions?