fs: move mkdtemp* functions near static functions
PR-URL: https://github.com/nodejs/node/pull/6828 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
dcbf246b35
commit
79a5eb1a65
80
lib/fs.js
80
lib/fs.js
@ -1596,6 +1596,47 @@ fs.realpath = function realpath(path, options, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
fs.mkdtemp = function(prefix, options, callback_) {
|
||||||
|
var callback = maybeCallback(callback_);
|
||||||
|
if (!prefix || typeof prefix !== 'string')
|
||||||
|
throw new TypeError('filename prefix is required');
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
if (typeof options === 'function') {
|
||||||
|
callback = options;
|
||||||
|
options = {};
|
||||||
|
} else if (typeof options === 'string') {
|
||||||
|
options = {encoding: options};
|
||||||
|
}
|
||||||
|
if (typeof options !== 'object')
|
||||||
|
throw new TypeError('"options" must be a string or an object');
|
||||||
|
|
||||||
|
if (!nullCheck(prefix, callback)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var req = new FSReqWrap();
|
||||||
|
req.oncomplete = callback;
|
||||||
|
|
||||||
|
binding.mkdtemp(prefix + 'XXXXXX', options.encoding, req);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
fs.mkdtempSync = function(prefix, options) {
|
||||||
|
if (!prefix || typeof prefix !== 'string')
|
||||||
|
throw new TypeError('filename prefix is required');
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
if (typeof options === 'string')
|
||||||
|
options = {encoding: options};
|
||||||
|
if (typeof options !== 'object')
|
||||||
|
throw new TypeError('"options" must be a string or an object');
|
||||||
|
nullCheck(prefix);
|
||||||
|
|
||||||
|
return binding.mkdtemp(prefix + 'XXXXXX', options.encoding);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var pool;
|
var pool;
|
||||||
|
|
||||||
function allocNewPool(poolSize) {
|
function allocNewPool(poolSize) {
|
||||||
@ -1999,42 +2040,3 @@ SyncWriteStream.prototype.destroy = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;
|
SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;
|
||||||
|
|
||||||
fs.mkdtemp = function(prefix, options, callback_) {
|
|
||||||
var callback = maybeCallback(callback_);
|
|
||||||
if (!prefix || typeof prefix !== 'string')
|
|
||||||
throw new TypeError('filename prefix is required');
|
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
if (typeof options === 'function') {
|
|
||||||
callback = options;
|
|
||||||
options = {};
|
|
||||||
} else if (typeof options === 'string') {
|
|
||||||
options = {encoding: options};
|
|
||||||
}
|
|
||||||
if (typeof options !== 'object')
|
|
||||||
throw new TypeError('"options" must be a string or an object');
|
|
||||||
|
|
||||||
if (!nullCheck(prefix, callback)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var req = new FSReqWrap();
|
|
||||||
req.oncomplete = callback;
|
|
||||||
|
|
||||||
binding.mkdtemp(prefix + 'XXXXXX', options.encoding, req);
|
|
||||||
};
|
|
||||||
|
|
||||||
fs.mkdtempSync = function(prefix, options) {
|
|
||||||
if (!prefix || typeof prefix !== 'string')
|
|
||||||
throw new TypeError('filename prefix is required');
|
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
if (typeof options === 'string')
|
|
||||||
options = {encoding: options};
|
|
||||||
if (typeof options !== 'object')
|
|
||||||
throw new TypeError('"options" must be a string or an object');
|
|
||||||
nullCheck(prefix);
|
|
||||||
|
|
||||||
return binding.mkdtemp(prefix + 'XXXXXX', options.encoding);
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user