Hi There,

I'm trying to tail a file in nodejs, the code is this:

var fs = require('fs');
var fName = 'file.txt';
fNameStat = fs.statSync(fName);
fs.watch(fName, function (evento, arquivo) {
fNameStatChanged = fs.statSync(arquivo);
console.log('file changed from ' + fNameStat.size + ' to ' +
fNameStatChanged.size);
 fs.open(fName, 'r', function(err, fd) {
        var newDataLength = fNameStatChanged.size - fNameStat.size;
    console.log(newDataLength);
          var buffer = new Buffer(newDataLength, 'utf-8');
    console.log(buffer);
    console.log(fd);
          fs.read(fd, buffer, 0, newDataLength, null, function (err,
bytesRead, newData) {
 if (err) {
    console.log(err);
 };
 console.log(newData.toString());

          });
            fNameStat = fs.statSync(fName);
         });

});


I'm getting this error:

fs.js:267
  binding.read(fd, buffer, offset, length, position, wrapper);
          ^
Error: Offset is out of bounds
    at Object.read (fs.js:267:11)
    at Object.oncomplete (/var/www/read/test.js:13:15)

Anyone know whats happened?

Regards*,*


*Felipe Silveira Mendes*Site <http://felipems.com.br> -
Twitter<https://twitter.com/felipesmendes>-
Blog <http://felipems.com.br/blog>
*Web Developer*
*(31) 8370-9090 (Claro)*
*(31) 9433-9310 (Tim)*
*[email protected] <[email protected]>*

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to