diff options
author | Sakthipriyan Vairamani <thechargingvolcano@gmail.com> | 2016-05-18 17:47:07 +0530 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-05-20 08:28:20 -0700 |
commit | 79a5eb1a65199bdaa359d3b4d1ac102d1e284078 (patch) | |
tree | d8a0acc20ac30743b877ea8cfdfabc3751905d88 /lib | |
parent | dcbf246b3512fd057a7799b0e0268efdc6798d49 (diff) | |
download | android-node-v8-79a5eb1a65199bdaa359d3b4d1ac102d1e284078.tar.gz android-node-v8-79a5eb1a65199bdaa359d3b4d1ac102d1e284078.tar.bz2 android-node-v8-79a5eb1a65199bdaa359d3b4d1ac102d1e284078.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 80 |
1 files changed, 41 insertions, 39 deletions
@@ -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; function allocNewPool(poolSize) { @@ -1999,42 +2040,3 @@ SyncWriteStream.prototype.destroy = function() { }; 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); -}; |