Repository navigation
Add the mkdtemp and mkstemp methods to fs #5332
Description
Activity
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Feb 19, 2016 I have opened a pull request implementing
fs.mkdtemp, libuv already providing it. Addingfs.mkstempwould require adding it in libuv first, so I guess this part of the proposal should be postponed./cc @nodejs/ctc ... overall I don't have a problem with this but aren't there userland modules that already cover this?
@jasnell in fact, I linked a userland version of this, but it does so:
- In a non de-facto standard way
- Highly inefficiently
As also pointed out, this function is part of the standard library of many other languages for its utility and because it's easy to mess it up. (See the python page about this.)
I think it's a worthfile feature to have. As for the API, I'd suggest following Linux's command scheme and only provide a single
fs.mktemp, with options for the variants or else we might end up with a lot of new methods. Also I think we'd want afs.mktempSync.It's a bit unfortunate that plain
mktempis not in libuv yet, maybe wait for it so we have a single, clean API?cc: @saghul
I wouldn't oppose adding this to libuv.
On Feb 20, 2016 12:22, "silverwind" notifications@github.com wrote:I think it's a worthfile feature to have. As for the API, I'd suggest
following Linux's scheme and only provide a single fs.mktemp, with
options for the variants. Also I think we'd want a fs.mktempSync. It's a
bit unfortunate that mktemp is not in libuv yet, maybe wait for it so we
have a single, clean API?cc: @saghul https://github.com/saghul
—
Reply to this email directly or view it on GitHub
#5332 (comment).That's good enough for me! I just want to make sure we're being deliberate
and careful about which pieces of userland functionality we're replacing or
duplicating.
On Feb 20, 2016 2:05 AM, "Florian Margaine" notifications@github.com
wrote:@jasnell https://github.com/jasnell in fact, I linked a userland
version of this, but it does so:- In a non de-facto standard way
- Highly inefficiently
As also pointed out, this function is part of the standard library of many
other languages for its utility and because it's easy to mess it up. (See
the python page about this.)—
Reply to this email directly or view it on GitHub
#5332 (comment).@silverwind I don't think we should have
fs.mktemp, for several reasons:- Having a single function with a flag argument is usually a code smell. (I guess that's debatable.)
- Only the CLI provides
mktemp, all the programming APIs providemkdtempandmkstemp.
@ralt let's say we implement all variants, how many methods are we looking at?
@silverwind 2. libc provides a couple more, but all the other APIs only provide
mkdtempandmkstemp.Closing this since
fs.mkdtempwas added in nodejs 5.10.0.
I would like to propose the addition of
mkdtempandmkstempto thefsmodule, to create a temporary directory and file, respectively.Some manual pages to start with:
So, this utility is fairly often needed for various reasons. Not providing it in nodejs itself means that people try to rewrite it, badly. (Or may I say, inefficiently.) (I'm obviously not trying to put the blame on someone there, except on node.js for not providing the functions ;-).)
This is part of the standard library in most other languages. Whether it's C, python, java, and surely others. I believe node.js would benefit its addition as well.