@ -6,8 +6,6 @@ var join = require('path').join;
var filename = join ( common . tmpDir , 'append.txt' ) ;
common . error ( 'appending to ' + filename ) ;
var currentFileData = 'ABCD' ;
var n = 220 ;
@ -28,11 +26,9 @@ fs.appendFile(filename, s, function(e) {
if ( e ) throw e ;
ncallbacks ++ ;
common . error ( 'appended to file' ) ;
fs . readFile ( filename , function ( e , buffer ) {
if ( e ) throw e ;
common . error ( 'file read' ) ;
ncallbacks ++ ;
assert . equal ( Buffer . byteLength ( s ) , buffer . length ) ;
} ) ;
@ -46,11 +42,9 @@ fs.appendFile(filename2, s, function(e) {
if ( e ) throw e ;
ncallbacks ++ ;
common . error ( 'appended to file2' ) ;
fs . readFile ( filename2 , function ( e , buffer ) {
if ( e ) throw e ;
common . error ( 'file2 read' ) ;
ncallbacks ++ ;
assert . equal ( Buffer . byteLength ( s ) + currentFileData . length , buffer . length ) ;
} ) ;
@ -61,17 +55,14 @@ var filename3 = join(common.tmpDir, 'append3.txt');
fs . writeFileSync ( filename3 , currentFileData ) ;
var buf = new Buffer ( s , 'utf8' ) ;
common . error ( 'appending to ' + filename3 ) ;
fs . appendFile ( filename3 , buf , function ( e ) {
if ( e ) throw e ;
ncallbacks ++ ;
common . error ( 'appended to file3' ) ;
fs . readFile ( filename3 , function ( e , buffer ) {
if ( e ) throw e ;
common . error ( 'file3 read' ) ;
ncallbacks ++ ;
assert . equal ( buf . length + currentFileData . length , buffer . length ) ;
} ) ;
@ -81,14 +72,11 @@ fs.appendFile(filename3, buf, function(e) {
var filename4 = join ( common . tmpDir , 'append4.txt' ) ;
fs . writeFileSync ( filename4 , currentFileData ) ;
common . error ( 'appending to ' + filename4 ) ;
var m = 0o600 ;
fs . appendFile ( filename4 , n , { mode : m } , function ( e ) {
if ( e ) throw e ;
ncallbacks ++ ;
common . error ( 'appended to file4' ) ;
// windows permissions aren't unix
if ( ! common . isWindows ) {
@ -98,7 +86,6 @@ fs.appendFile(filename4, n, { mode: m }, function(e) {
fs . readFile ( filename4 , function ( e , buffer ) {
if ( e ) throw e ;
common . error ( 'file4 read' ) ;
ncallbacks ++ ;
assert . equal ( Buffer . byteLength ( '' + n ) + currentFileData . length ,
buffer . length ) ;
@ -106,7 +93,6 @@ fs.appendFile(filename4, n, { mode: m }, function(e) {
} ) ;
process . on ( 'exit' , function ( ) {
common . error ( 'done' ) ;
assert . equal ( 8 , ncallbacks ) ;
fs . unlinkSync ( filename ) ;