-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Description
- Version: master
- Platform: all
- Subsystem: fs
As I just found out from #15409, you can call fs.truncate with an fd:
> var fd = fs.openSync('asdf.txt', 'r+')
undefined
> fs.truncateSync(fd)
undefinedBut this behavior is surprising, since there's fs.ftruncate for fds and it's easy to overlook the note in the documentation for fs.truncate.
Options:
- Improve documentation for
fs.truncateto make it more obvious that it also takesfds. For instance,path <string> | <Buffer>needs to be replaced with something likepathOrFd <string> | <Buffer> | <number>, andAsynchronous truncate(2).needs to be replaced with something likeAsynchronous truncate(2) or ftruncate(2) depending on the argument. - Phase out
fdsupport infs.truncate. This would be my preference, since it would avoid having two functions that can do the same thing, and it would make code such asfs.truncate(f)more readable because it would be obvious thatfis a path and not anfd.
Metadata
Metadata
Assignees
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.