Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/fs-extra/lib/move/ |
Upload File : |
'use strict' // most of this code was written by Andrew Kelley // licensed under the BSD license: see // https://github.com/andrewrk/node-mv/blob/master/package.json // this needs a cleanup const u = require('universalify').fromCallback const fs = require('graceful-fs') const ncp = require('../copy/ncp') const path = require('path') const remove = require('../remove').remove const mkdirp = require('../mkdirs').mkdirs function move (source, dest, options, callback) { if (typeof options === 'function') { callback = options options = {} } const shouldMkdirp = ('mkdirp' in options) ? options.mkdirp : true const overwrite = options.overwrite || options.clobber || false if (shouldMkdirp) { mkdirs() } else { doRename() } function mkdirs () { mkdirp(path.dirname(dest), err => { if (err) return callback(err) doRename() }) } function doRename () { if (path.resolve(source) === path.resolve(dest)) { fs.access(source, callback) } else if (overwrite) { fs.rename(source, dest, err => { if (!err) return callback() if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST') { remove(dest, err => { if (err) return callback(err) options.overwrite = false // just overwriteed it, no need to do it again move(source, dest, options, callback) }) return } // weird Windows shit if (err.code === 'EPERM') { setTimeout(() => { remove(dest, err => { if (err) return callback(err) options.overwrite = false move(source, dest, options, callback) }) }, 200) return } if (err.code !== 'EXDEV') return callback(err) moveAcrossDevice(source, dest, overwrite, callback) }) } else { fs.link(source, dest, err => { if (err) { if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM' || err.code === 'ENOTSUP') { moveAcrossDevice(source, dest, overwrite, callback) return } callback(err) return } fs.unlink(source, callback) }) } } } function moveAcrossDevice (source, dest, overwrite, callback) { fs.stat(source, (err, stat) => { if (err) { callback(err) return } if (stat.isDirectory()) { moveDirAcrossDevice(source, dest, overwrite, callback) } else { moveFileAcrossDevice(source, dest, overwrite, callback) } }) } function moveFileAcrossDevice (source, dest, overwrite, callback) { const flags = overwrite ? 'w' : 'wx' const ins = fs.createReadStream(source) const outs = fs.createWriteStream(dest, { flags }) ins.on('error', err => { ins.destroy() outs.destroy() outs.removeListener('close', onClose) // may want to create a directory but `out` line above // creates an empty file for us: See #108 // don't care about error here fs.unlink(dest, () => { // note: `err` here is from the input stream errror if (err.code === 'EISDIR' || err.code === 'EPERM') { moveDirAcrossDevice(source, dest, overwrite, callback) } else { callback(err) } }) }) outs.on('error', err => { ins.destroy() outs.destroy() outs.removeListener('close', onClose) callback(err) }) outs.once('close', onClose) ins.pipe(outs) function onClose () { fs.unlink(source, callback) } } function moveDirAcrossDevice (source, dest, overwrite, callback) { const options = { overwrite: false } if (overwrite) { remove(dest, err => { if (err) return callback(err) startNcp() }) } else { startNcp() } function startNcp () { ncp(source, dest, options, err => { if (err) return callback(err) remove(source, callback) }) } } module.exports = { move: u(move) }