Fix failing null-byte case in PhantomJS for fs.truncate. Fixes #117

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-02-18 11:02:08 -05:00
parent 6ac7341edd
commit a33c2bd358
1 changed files with 6 additions and 0 deletions

View File

@ -2291,7 +2291,13 @@ define(function(require) {
if(error) callback(error); if(error) callback(error);
}; };
FileSystem.prototype.truncate = function(path, length, callback) { FileSystem.prototype.truncate = function(path, length, callback) {
// Follow node.js in allowing the `length` to be optional
if(typeof length === 'function') {
callback = length;
length = 0;
}
callback = maybeCallback(callback); callback = maybeCallback(callback);
length = typeof length === 'number' ? length : 0;
var fs = this; var fs = this;
var error = fs.queueOrRun( var error = fs.queueOrRun(
function() { function() {