My problem is that I cannot be sure when the file was successfully written and the file was closed. Consider the following case:
var fs = require('fs'); var outs = fs.createWriteStream('/tmp/file.txt'); var ins = <some input stream> ... ins.on('data', function(chunk) { out.write(chunk); }); ... ins.on('end', function() { outs.end(); outs.destroySoon(); fs.stat('/tmp/file.txt', function(err, info) {
So, how can I make or otherwise make sure that the file has been cleaned correctly before accessing it? I must be sure that the file is there and is complete, since my code must spawn an external process for reading and processing the file.
Teemu ikonen
source share