fs: remove fs.sendfile()
Said function has been broken (and useless) since v0.6.0. Remove it altogether. Fixes #3854.
This commit is contained in:
parent
c4fc0febfa
commit
910e24b53d
@ -609,14 +609,6 @@ fs.mkdirSync = function(path, mode) {
|
||||
modeNum(mode, 511 /*=0777*/));
|
||||
};
|
||||
|
||||
fs.sendfile = function(outFd, inFd, inOffset, length, callback) {
|
||||
binding.sendfile(outFd, inFd, inOffset, length, makeCallback(callback));
|
||||
};
|
||||
|
||||
fs.sendfileSync = function(outFd, inFd, inOffset, length) {
|
||||
return binding.sendfile(outFd, inFd, inOffset, length);
|
||||
};
|
||||
|
||||
fs.readdir = function(path, callback) {
|
||||
callback = makeCallback(callback);
|
||||
if (!nullCheck(path, callback)) return;
|
||||
|
@ -144,8 +144,6 @@ static void After(uv_fs_t *req) {
|
||||
break;
|
||||
|
||||
case UV_FS_OPEN:
|
||||
/* pass thru */
|
||||
case UV_FS_SENDFILE:
|
||||
argv[1] = Integer::New(req->result);
|
||||
break;
|
||||
|
||||
@ -603,30 +601,6 @@ static Handle<Value> MKDir(const Arguments& args) {
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SendFile(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
if (args.Length() < 4 ||
|
||||
!args[0]->IsUint32() ||
|
||||
!args[1]->IsUint32() ||
|
||||
!args[2]->IsUint32() ||
|
||||
!args[3]->IsUint32()) {
|
||||
return THROW_BAD_ARGS;
|
||||
}
|
||||
|
||||
int out_fd = args[0]->Uint32Value();
|
||||
int in_fd = args[1]->Uint32Value();
|
||||
off_t in_offset = args[2]->Uint32Value();
|
||||
size_t length = args[3]->Uint32Value();
|
||||
|
||||
if (args[4]->IsFunction()) {
|
||||
ASYNC_CALL(sendfile, args[4], out_fd, in_fd, in_offset, length)
|
||||
} else {
|
||||
SYNC_CALL(sendfile, 0, out_fd, in_fd, in_offset, length)
|
||||
return scope.Close(Integer::New(SYNC_RESULT));
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> ReadDir(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
@ -957,7 +931,6 @@ void File::Initialize(Handle<Object> target) {
|
||||
NODE_SET_METHOD(target, "ftruncate", FTruncate);
|
||||
NODE_SET_METHOD(target, "rmdir", RMDir);
|
||||
NODE_SET_METHOD(target, "mkdir", MKDir);
|
||||
NODE_SET_METHOD(target, "sendfile", SendFile);
|
||||
NODE_SET_METHOD(target, "readdir", ReadDir);
|
||||
NODE_SET_METHOD(target, "stat", Stat);
|
||||
NODE_SET_METHOD(target, "lstat", LStat);
|
||||
|
@ -1,52 +0,0 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
var net = require('net');
|
||||
var util = require('util');
|
||||
var x = path.join(common.fixturesDir, 'x.txt');
|
||||
var expected = 'xyz';
|
||||
|
||||
var server = net.createServer(function(socket) {
|
||||
socket.on('receive', function(data) {
|
||||
found = data;
|
||||
client.close();
|
||||
socket.close();
|
||||
server.close();
|
||||
assert.equal(expected, found);
|
||||
});
|
||||
});
|
||||
server.listen(common.PORT);
|
||||
|
||||
var client = net.createConnection(common.PORT);
|
||||
client.on('connect', function() {
|
||||
fs.open(x, 'r').addCallback(function(fd) {
|
||||
fs.sendfile(client.fd, fd, 0, expected.length)
|
||||
.addCallback(function(size) {
|
||||
assert.equal(expected.length, size);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user