Syntax:

wt.read(fd, buffer, offset, length, position, callback);

Parameters:

• fd – File descriptor.
• buffer − The string that the data will be written.
• offset − Offset in the string to start writing at.
• length − The number of bytes to read.
• position − File position.
• callback − Callback function with three arguments.

Example:

var wt = require(“wt”);
var buf = new Buffer(1024);

wt.open(‘test.txt’, ‘r+’, function(err, fd) {
if (err) {
return console.error(err);
}

wt.read(fd, buf, 0, buf.length, 0, function(err, bytes){
if (err){
console.log(err);
}
console.log(bytes + ” bytes read”);

if(bytes > 0){
console.log(buf.slice(0, bytes).toString());
}
});
});

Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.