From 5bf56882e13128bc67517c5e1a812e969397c8c0 Mon Sep 17 00:00:00 2001 From: yorkie Date: Wed, 25 Nov 2015 12:40:42 +0800 Subject: [PATCH] fs,doc: use `target` instead of `destination` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/3912 Reviewed-By: James M Snell Reviewed-By: Evan Lucas Reviewed-By: Michaƫl Zasso Reviewed-By: Bert Belder Reviewed-By: Colin Ihrig --- doc/api/fs.markdown | 12 +++++++++--- lib/fs.js | 12 ++++++------ src/node_file.cc | 10 +++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index 97903dbd469dae..ed114ed094c575 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -664,16 +664,22 @@ information. Synchronous stat(2). Returns an instance of `fs.Stats`. -## fs.symlink(destination, path[, type], callback) +## fs.symlink(target, path[, type], callback) Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. The `type` argument can be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using -`'junction'`, the `destination` argument will automatically be normalized to absolute path. +`'junction'`, the `target` argument will automatically be normalized to absolute path. -## fs.symlinkSync(destination, path[, type]) +Here is an example below: + + fs.symlink('./foo', './new-port'); + +It would create a symlic link named with "new-port" that points to "foo". + +## fs.symlinkSync(target, path[, type]) Synchronous symlink(2). Returns `undefined`. diff --git a/lib/fs.js b/lib/fs.js index cd39cc9d83fcc1..57e9220a149f28 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -872,29 +872,29 @@ function preprocessSymlinkDestination(path, type, linkPath) { } } -fs.symlink = function(destination, path, type_, callback_) { +fs.symlink = function(target, path, type_, callback_) { var type = (typeof type_ === 'string' ? type_ : null); var callback = makeCallback(arguments[arguments.length - 1]); - if (!nullCheck(destination, callback)) return; + if (!nullCheck(target, callback)) return; if (!nullCheck(path, callback)) return; var req = new FSReqWrap(); req.oncomplete = callback; - binding.symlink(preprocessSymlinkDestination(destination, type, path), + binding.symlink(preprocessSymlinkDestination(target, type, path), pathModule._makeLong(path), type, req); }; -fs.symlinkSync = function(destination, path, type) { +fs.symlinkSync = function(target, path, type) { type = (typeof type === 'string' ? type : null); - nullCheck(destination); + nullCheck(target); nullCheck(path); - return binding.symlink(preprocessSymlinkDestination(destination, type, path), + return binding.symlink(preprocessSymlinkDestination(target, type, path), pathModule._makeLong(path), type); }; diff --git a/src/node_file.cc b/src/node_file.cc index b84e0e44c442b0..b6ef7d5b78f70e 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -580,15 +580,15 @@ static void Symlink(const FunctionCallbackInfo& args) { int len = args.Length(); if (len < 1) - return TYPE_ERROR("dest path required"); + return TYPE_ERROR("target path required"); if (len < 2) return TYPE_ERROR("src path required"); if (!args[0]->IsString()) - return TYPE_ERROR("dest path must be a string"); + return TYPE_ERROR("target path must be a string"); if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); - node::Utf8Value dest(env->isolate(), args[0]); + node::Utf8Value target(env->isolate(), args[0]); node::Utf8Value path(env->isolate(), args[1]); int flags = 0; @@ -604,9 +604,9 @@ static void Symlink(const FunctionCallbackInfo& args) { } if (args[3]->IsObject()) { - ASYNC_DEST_CALL(symlink, args[3], *path, *dest, *path, flags) + ASYNC_DEST_CALL(symlink, args[3], *path, *target, *path, flags) } else { - SYNC_DEST_CALL(symlink, *dest, *path, *dest, *path, flags) + SYNC_DEST_CALL(symlink, *target, *path, *target, *path, flags) } }