Skip to content

Commit

Permalink
fs,doc: use target instead of destination
Browse files Browse the repository at this point in the history
PR-URL: #3912
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
yorkie authored and Myles Borins committed Dec 29, 2015
1 parent e1f2810 commit a221308
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
12 changes: 9 additions & 3 deletions doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
12 changes: 6 additions & 6 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
10 changes: 5 additions & 5 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,15 @@ static void Symlink(const FunctionCallbackInfo<Value>& 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;

Expand All @@ -604,9 +604,9 @@ static void Symlink(const FunctionCallbackInfo<Value>& 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)
}
}

Expand Down

0 comments on commit a221308

Please sign in to comment.