/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['streams/RollingFileStream.js']) {
  _$jscoverage['streams/RollingFileStream.js'] = [];
  _$jscoverage['streams/RollingFileStream.js'][1] = 0;
  _$jscoverage['streams/RollingFileStream.js'][2] = 0;
  _$jscoverage['streams/RollingFileStream.js'][9] = 0;
  _$jscoverage['streams/RollingFileStream.js'][11] = 0;
  _$jscoverage['streams/RollingFileStream.js'][12] = 0;
  _$jscoverage['streams/RollingFileStream.js'][13] = 0;
  _$jscoverage['streams/RollingFileStream.js'][15] = 0;
  _$jscoverage['streams/RollingFileStream.js'][16] = 0;
  _$jscoverage['streams/RollingFileStream.js'][17] = 0;
  _$jscoverage['streams/RollingFileStream.js'][21] = 0;
  _$jscoverage['streams/RollingFileStream.js'][23] = 0;
  _$jscoverage['streams/RollingFileStream.js'][25] = 0;
  _$jscoverage['streams/RollingFileStream.js'][27] = 0;
  _$jscoverage['streams/RollingFileStream.js'][28] = 0;
  _$jscoverage['streams/RollingFileStream.js'][29] = 0;
  _$jscoverage['streams/RollingFileStream.js'][32] = 0;
  _$jscoverage['streams/RollingFileStream.js'][33] = 0;
  _$jscoverage['streams/RollingFileStream.js'][36] = 0;
  _$jscoverage['streams/RollingFileStream.js'][37] = 0;
  _$jscoverage['streams/RollingFileStream.js'][40] = 0;
  _$jscoverage['streams/RollingFileStream.js'][41] = 0;
  _$jscoverage['streams/RollingFileStream.js'][44] = 0;
  _$jscoverage['streams/RollingFileStream.js'][45] = 0;
  _$jscoverage['streams/RollingFileStream.js'][46] = 0;
  _$jscoverage['streams/RollingFileStream.js'][47] = 0;
  _$jscoverage['streams/RollingFileStream.js'][48] = 0;
  _$jscoverage['streams/RollingFileStream.js'][50] = 0;
  _$jscoverage['streams/RollingFileStream.js'][54] = 0;
  _$jscoverage['streams/RollingFileStream.js'][55] = 0;
  _$jscoverage['streams/RollingFileStream.js'][56] = 0;
  _$jscoverage['streams/RollingFileStream.js'][57] = 0;
  _$jscoverage['streams/RollingFileStream.js'][60] = 0;
  _$jscoverage['streams/RollingFileStream.js'][62] = 0;
  _$jscoverage['streams/RollingFileStream.js'][63] = 0;
  _$jscoverage['streams/RollingFileStream.js'][66] = 0;
  _$jscoverage['streams/RollingFileStream.js'][70] = 0;
  _$jscoverage['streams/RollingFileStream.js'][72] = 0;
  _$jscoverage['streams/RollingFileStream.js'][73] = 0;
  _$jscoverage['streams/RollingFileStream.js'][74] = 0;
  _$jscoverage['streams/RollingFileStream.js'][82] = 0;
  _$jscoverage['streams/RollingFileStream.js'][83] = 0;
}
_$jscoverage['streams/RollingFileStream.js'][1]++;
"use strict";
_$jscoverage['streams/RollingFileStream.js'][2]++;
var BaseRollingFileStream = require("./BaseRollingFileStream"), debug = require("../debug")("RollingFileStream"), util = require("util"), path = require("path"), fs = require("fs"), async = require("async");
_$jscoverage['streams/RollingFileStream.js'][9]++;
module.exports = RollingFileStream;
_$jscoverage['streams/RollingFileStream.js'][11]++;
function RollingFileStream(filename, size, backups, options) {
  _$jscoverage['streams/RollingFileStream.js'][12]++;
  this.size = size;
  _$jscoverage['streams/RollingFileStream.js'][13]++;
  this.backups = backups || 1;
  _$jscoverage['streams/RollingFileStream.js'][15]++;
  function throwErrorIfArgumentsAreNotValid() {
    _$jscoverage['streams/RollingFileStream.js'][16]++;
    if (! filename || ! size || size <= 0) {
      _$jscoverage['streams/RollingFileStream.js'][17]++;
      throw new Error("You must specify a filename and file size");
    }
}
  _$jscoverage['streams/RollingFileStream.js'][21]++;
  throwErrorIfArgumentsAreNotValid();
  _$jscoverage['streams/RollingFileStream.js'][23]++;
  RollingFileStream.super_.call(this, filename, options);
}
_$jscoverage['streams/RollingFileStream.js'][25]++;
util.inherits(RollingFileStream, BaseRollingFileStream);
_$jscoverage['streams/RollingFileStream.js'][27]++;
RollingFileStream.prototype.shouldRoll = (function () {
  _$jscoverage['streams/RollingFileStream.js'][28]++;
  debug("should roll with current size %d, and max size %d", this.currentSize, this.size);
  _$jscoverage['streams/RollingFileStream.js'][29]++;
  return this.currentSize >= this.size;
});
_$jscoverage['streams/RollingFileStream.js'][32]++;
RollingFileStream.prototype.roll = (function (filename, callback) {
  _$jscoverage['streams/RollingFileStream.js'][33]++;
  var that = this, nameMatcher = new RegExp("^" + path.basename(filename));
  _$jscoverage['streams/RollingFileStream.js'][36]++;
  function justTheseFiles(item) {
    _$jscoverage['streams/RollingFileStream.js'][37]++;
    return nameMatcher.test(item);
}
  _$jscoverage['streams/RollingFileStream.js'][40]++;
  function index(filename_) {
    _$jscoverage['streams/RollingFileStream.js'][41]++;
    return parseInt(filename_.substring((path.basename(filename) + ".").length), 10) || 0;
}
  _$jscoverage['streams/RollingFileStream.js'][44]++;
  function byIndex(a, b) {
    _$jscoverage['streams/RollingFileStream.js'][45]++;
    if (index(a) > index(b)) {
      _$jscoverage['streams/RollingFileStream.js'][46]++;
      return 1;
    }
    else {
      _$jscoverage['streams/RollingFileStream.js'][47]++;
      if (index(a) < index(b)) {
        _$jscoverage['streams/RollingFileStream.js'][48]++;
        return -1;
      }
      else {
        _$jscoverage['streams/RollingFileStream.js'][50]++;
        return 0;
      }
    }
}
  _$jscoverage['streams/RollingFileStream.js'][54]++;
  function increaseFileIndex(fileToRename, cb) {
    _$jscoverage['streams/RollingFileStream.js'][55]++;
    var idx = index(fileToRename);
    _$jscoverage['streams/RollingFileStream.js'][56]++;
    debug("Index of " + fileToRename + " is " + idx);
    _$jscoverage['streams/RollingFileStream.js'][57]++;
    if (idx < that.backups) {
      _$jscoverage['streams/RollingFileStream.js'][60]++;
      fs.unlink(filename + "." + (idx + 1), (function (err) {
  _$jscoverage['streams/RollingFileStream.js'][62]++;
  debug("Renaming " + fileToRename + " -> " + filename + "." + (idx + 1));
  _$jscoverage['streams/RollingFileStream.js'][63]++;
  fs.rename(path.join(path.dirname(filename), fileToRename), filename + "." + (idx + 1), cb);
}));
    }
    else {
      _$jscoverage['streams/RollingFileStream.js'][66]++;
      cb();
    }
}
  _$jscoverage['streams/RollingFileStream.js'][70]++;
  function renameTheFiles(cb) {
    _$jscoverage['streams/RollingFileStream.js'][72]++;
    debug("Renaming the old files");
    _$jscoverage['streams/RollingFileStream.js'][73]++;
    fs.readdir(path.dirname(filename), (function (err, files) {
  _$jscoverage['streams/RollingFileStream.js'][74]++;
  async.forEachSeries(files.filter(justTheseFiles).sort(byIndex).reverse(), increaseFileIndex, cb);
}));
}
  _$jscoverage['streams/RollingFileStream.js'][82]++;
  debug("Rolling, rolling, rolling");
  _$jscoverage['streams/RollingFileStream.js'][83]++;
  async.series([this.closeTheStream.bind(this), renameTheFiles, this.openTheStream.bind(this)], callback);
});
_$jscoverage['streams/RollingFileStream.js'].source = ["\"use strict\";","var BaseRollingFileStream = require('./BaseRollingFileStream')",", debug = require('../debug')('RollingFileStream')",", util = require('util')",", path = require('path')",", fs = require('fs')",", async = require('async');","","module.exports = RollingFileStream;","","function RollingFileStream (filename, size, backups, options) {","  this.size = size;","  this.backups = backups || 1;","  ","  function throwErrorIfArgumentsAreNotValid() {","    if (!filename || !size || size &lt;= 0) {","      throw new Error(\"You must specify a filename and file size\");","    }","  }","  ","  throwErrorIfArgumentsAreNotValid();","  ","  RollingFileStream.super_.call(this, filename, options);","}","util.inherits(RollingFileStream, BaseRollingFileStream);","","RollingFileStream.prototype.shouldRoll = function() {","  debug(\"should roll with current size %d, and max size %d\", this.currentSize, this.size);","  return this.currentSize &gt;= this.size;","};","","RollingFileStream.prototype.roll = function(filename, callback) {","  var that = this,","  nameMatcher = new RegExp('^' + path.basename(filename));","  ","  function justTheseFiles (item) {","    return nameMatcher.test(item);","  }","  ","  function index(filename_) {","    return parseInt(filename_.substring((path.basename(filename) + '.').length), 10) || 0;","  }","  ","  function byIndex(a, b) {","    if (index(a) &gt; index(b)) {","      return 1;","    } else if (index(a) &lt; index(b) ) {","      return -1;","    } else {","      return 0;","    }","  }","","  function increaseFileIndex (fileToRename, cb) {","    var idx = index(fileToRename);","    debug('Index of ' + fileToRename + ' is ' + idx);","    if (idx &lt; that.backups) {","      //on windows, you can get a EEXIST error if you rename a file to an existing file","      //so, we'll try to delete the file we're renaming to first","      fs.unlink(filename + '.' + (idx+1), function (err) {","        //ignore err: if we could not delete, it's most likely that it doesn't exist","        debug('Renaming ' + fileToRename + ' -&gt; ' + filename + '.' + (idx+1));","        fs.rename(path.join(path.dirname(filename), fileToRename), filename + '.' + (idx + 1), cb);","      });","    } else {","      cb();","    }","  }","","  function renameTheFiles(cb) {","    //roll the backups (rename file.n to file.n+1, where n &lt;= numBackups)","    debug(\"Renaming the old files\");","    fs.readdir(path.dirname(filename), function (err, files) {","      async.forEachSeries(","        files.filter(justTheseFiles).sort(byIndex).reverse(),","        increaseFileIndex,","        cb","      );","    });","  }","","  debug(\"Rolling, rolling, rolling\");","  async.series([","    this.closeTheStream.bind(this),","    renameTheFiles,","    this.openTheStream.bind(this)","  ], callback);","","};"];
