Thursday, 13 April 2017

getting 4 byte from a file and convert it to timestamp

I am facing issue in getting data from a file as a buffer and then converting it into a long sample code is

var fs = require('fs');

fs.open('24.mkt', 'r', function(status, fd) {
  if (status) {
    console.log(status.message);
    return;
  }
  var buffer = new Buffer(4);
  fs.read(fd, buffer, 0, 4, 0, function(err, num) {
    console.log(buffer.values());
  });
});

file link - > https://archive.org/download/kamo_24/24.mkt

first 4 bytes contains Timestamp in Long in 4 Bytes



via Rahul Kamboj

No comments:

Post a Comment