Server IP : 127.0.0.2 / Your IP : 52.14.228.67 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,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,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/nodejs/fstream/lib/ |
Upload File : |
module.exports = LinkWriter var fs = require("graceful-fs") , Writer = require("./writer.js") , inherits = require("inherits") , path = require("path") , rimraf = require("rimraf") inherits(LinkWriter, Writer) function LinkWriter (props) { var me = this if (!(me instanceof LinkWriter)) throw new Error( "LinkWriter must be called as constructor.") // should already be established as a Link type if (!((props.type === "Link" && props.Link) || (props.type === "SymbolicLink" && props.SymbolicLink))) { throw new Error("Non-link type "+ props.type) } if (props.linkpath === "") props.linkpath = "." if (!props.linkpath) { me.error("Need linkpath property to create " + props.type) } Writer.call(this, props) } LinkWriter.prototype._create = function () { // console.error(" LW _create") var me = this , hard = me.type === "Link" || process.platform === "win32" , link = hard ? "link" : "symlink" , lp = hard ? path.resolve(me.dirname, me.linkpath) : me.linkpath // can only change the link path by clobbering // For hard links, let's just assume that's always the case, since // there's no good way to read them if we don't already know. if (hard) return clobber(me, lp, link) fs.readlink(me._path, function (er, p) { // only skip creation if it's exactly the same link if (p && p === lp) return finish(me) clobber(me, lp, link) }) } function clobber (me, lp, link) { rimraf(me._path, function (er) { if (er) return me.error(er) create(me, lp, link) }) } function create (me, lp, link) { fs[link](lp, me._path, function (er) { // if this is a hard link, and we're in the process of writing out a // directory, it's very possible that the thing we're linking to // doesn't exist yet (especially if it was intended as a symlink), // so swallow ENOENT errors here and just soldier in. // Additionally, an EPERM or EACCES can happen on win32 if it's trying // to make a link to a directory. Again, just skip it. // A better solution would be to have fs.symlink be supported on // windows in some nice fashion. if (er) { if ((er.code === "ENOENT" || er.code === "EACCES" || er.code === "EPERM" ) && process.platform === "win32") { me.ready = true me.emit("ready") me.emit("end") me.emit("close") me.end = me._finish = function () {} } else return me.error(er) } finish(me) }) } function finish (me) { me.ready = true me.emit("ready") if (me._ended && !me._finished) me._finish() } LinkWriter.prototype.end = function () { // console.error("LW finish in end") this._ended = true if (this.ready) { this._finished = true this._finish() } }