Console
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/leitor/teste.js:16:15)
Node Version v0.6.17
*Att,*
*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]>*
2013/12/9 Fedor Indutny <[email protected]>
> What does it log to console? What node.js version are you using?
>
> On Mon, Dec 9, 2013 at 2:17 PM, Felipe Silveira <[email protected]>
> wrote:
> > Thank bro to help,
> >
> > I change to this code and get the same error:
> >
> > var fs = require('fs');
> > var fName = 'text.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);
> > console.log(buffer);
> > console.log(fd);
> > if(newDataLength < 0 ){
> > newDataLength = 0;
> > }
> > fs.read(fd, buffer, 0, newDataLength, null, function (err,
> > bytesRead, newData) {
> > if (err) {
> > console.log(err);
> > };
> > console.log(newData.toString());
> >
> > });
> > fNameStat = fs.statSync(fName);
> > });
> >
> > });
> >
> >
> > On Monday, December 9, 2013 8:00:56 AM UTC-2, Fedor Indutny wrote:
> >>
> >> Hello!
> >>
> >> Perhaps, you are trying to create a Buffer of negative length?
> >>
> >> Also, I believe, that you do not need to pass encoding argument to the
> >> Buffer's constructor if you're creating just a fixed-size buffer.
> >>
> >> On Mon, Dec 9, 2013 at 1:58 PM, Felipe Silveira <[email protected]
> >
> >> wrote:
> >> > 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 - Twitter - Blog
> >> > Web Developer
> >> > (31) 8370-9090 (Claro)
> >> > (31) 9433-9310 (Tim)
> >> > [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.
>
--
--
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.