<commit_before>
var fs = require('fs');

// Read file content and stat data
module.exports = function readFile(path, callback) {
  var ret = { 'path': path };

	fs.open(path, 'r', function (error, fd) {
    if (error) return callback(error, null);

    fs.fstat(fd, function (error, stat) {
      if (error) return callback(error, null);
      ret.mtime = stat.mtime;
      ret.size = stat.size;
      ret.content = new Buffer(stat.size);

      fs.read(fd, ret.content, 0, stat.size, 0, function (error) {
        if (error) return callback(error, null);
<commit_msg>[fix] support empty files<commit_after>
var fs = require('fs');

// Read file content and stat data
module.exports = function readFile(path, callback) {
  var ret = { 'path': path };

	fs.open(path, 'r', function (error, fd) {
    if (error) return callback(error, null);

    fs.fstat(fd, function (error, stat) {
      if (error) return callback(error, null);
      ret.mtime = stat.mtime;
      ret.size = stat.size;
      ret.content = new Buffer(stat.size);

      if (stat.size === 0) {
        return callback(null, ret);
      }

      fs.read(fd, ret.content, 0, stat.size, 0, function (error) {
        if (error) {
          console.log(stack);
          return callback(error, null);
        }

{'fraction_non_alphanumeric': 0.14913657770800628, 'fraction_numerical': 0.003924646781789639, 'mean_word_length': 2.7610619469026547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '614818', 'n_tokens_mistral': 423, 'n_tokens_neox': 409, 'n_words': 122}