@ -893,11 +893,16 @@ added: v0.1.21
Synchronous mkdir(2). Returns `undefined` .
Synchronous mkdir(2). Returns `undefined` .
## fs.mkdtemp(prefix, callback)
## fs.mkdtemp(prefix[, options] , callback)
<!-- YAML
<!-- YAML
added: v5.10.0
added: v5.10.0
-->
-->
* `prefix` {String}
* `options` {String | Object}
* `encoding` {String} default = `'utf8'`
* `callback` {Function}
Creates a unique temporary directory.
Creates a unique temporary directory.
Generates six random characters to be appended behind a required
Generates six random characters to be appended behind a required
@ -906,10 +911,14 @@ Generates six random characters to be appended behind a required
The created folder path is passed as a string to the callback's second
The created folder path is passed as a string to the callback's second
parameter.
parameter.
The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use.
Example:
Example:
```js
```js
fs.mkdtemp('/tmp/foo-', (err, folder) => {
fs.mkdtemp('/tmp/foo-', (err, folder) => {
if (err) throw err;
console.log(folder);
console.log(folder);
// Prints: /tmp/foo-itXde2
// Prints: /tmp/foo-itXde2
});
});
@ -946,14 +955,21 @@ fs.mkdtemp(tmpDir + path.sep, (err, folder) => {
});
});
```
```
## fs.mkdtempSync(prefix)
## fs.mkdtempSync(prefix[, options] )
<!-- YAML
<!-- YAML
added: v5.10.0
added: v5.10.0
-->
-->
* `prefix` {String}
* `options` {String | Object}
* `encoding` {String} default = `'utf8'`
The synchronous version of [`fs.mkdtemp()`][]. Returns the created
The synchronous version of [`fs.mkdtemp()`][]. Returns the created
folder path.
folder path.
The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use.
## fs.open(path, flags[, mode], callback)
## fs.open(path, flags[, mode], callback)
<!-- YAML
<!-- YAML
added: v0.0.2
added: v0.0.2