fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
if (writeErr) {
fs.close(fd, function() {
- if (callback) callback(writeErr);
+ callback(writeErr);
});
} else {
if (written === length) {
var flag = options.flag || 'w';
fs.open(path, flag, options.mode, function(openErr, fd) {
if (openErr) {
- if (callback) callback(openErr);
+ callback(openErr);
} else {
var buffer = (data instanceof Buffer) ? data : new Buffer('' + data,
options.encoding || 'utf8');