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

doc: clarify behaviour of writeFile(fd) #27282

Closed
wants to merge 1 commit into from

Conversation

sam-github
Copy link
Contributor

This is a continuing source of confusion, attempt to make it even more
clear.

Fixes: #24923

Checklist

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Apr 17, 2019
doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated
When `file` is a file descriptor, the behaviour is almost identical to directly
calling [`fs.write()`][] like:
```javascript
fs.write(fd, Buffer.from(options.encoding), callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.from(options.encoding) seems a bit confusing here. Is something missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearer now?

doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Show resolved Hide resolved
@@ -3615,14 +3619,33 @@ It is unsafe to use `fs.writeFile()` multiple times on the same file without
waiting for the callback. For this scenario, [`fs.createWriteStream()`][] is
recommended.

### File Descriptors
1. Any specified file descriptor has to support writing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are 1 and 2 skipped intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now, the difference from fs.write() is described, rather than the previous more complicated way of describing the fd behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 was skipped as well -- which makes the entire previous list being replaced.

This is a continuing source of confusion, attempt to make it even more
clear.

Fixes: nodejs#24923
@sam-github
Copy link
Contributor Author

@vsemozhetbyt PTAL

@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 24, 2019
@sam-github
Copy link
Contributor Author

sam-github added a commit to sam-github/node that referenced this pull request Apr 24, 2019
This is a continuing source of confusion, attempt to make it even more
clear.

Fixes: nodejs#24923

PR-URL: nodejs#27282
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@sam-github
Copy link
Contributor Author

Landed in a763de1

@sam-github sam-github closed this Apr 24, 2019
@sam-github sam-github deleted the clarify-writefile branch April 24, 2019 16:04
targos pushed a commit that referenced this pull request Apr 27, 2019
This is a continuing source of confusion, attempt to make it even more
clear.

Fixes: #24923

PR-URL: #27282
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@targos targos mentioned this pull request Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs writeFile after truncate doesn't write at beginning of the file
4 participants