Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created March 22, 2010 07:34
Show Gist options
  • Save billywhizz/339870 to your computer and use it in GitHub Desktop.
Save billywhizz/339870 to your computer and use it in GitHub Desktop.
require("../common");
var path = require('path');
var fs = require('fs');
var got_error = false;
var success_count = 0;
var file = path.join(fixturesDir, "a.js");
fs.open(file, process.O_WRONLY | process.O_APPEND, 0777, function (err, fd) {
try {
if(err) {
got_error = true;
}
else {
if(typeof(fs.fdatasyncSync(fd)) == "undefined") {
puts("fdatasync SYNC: ok");
success_count++;
}
else {
got_error = true;
}
if(typeof(fs.fsyncSync(fd)) == "undefined") {
puts("fsync SYNC: ok");
success_count++;
}
else {
got_error = true;
}
fs.fdatasync(fd, function(err) {
if(err) {
got_error = true;
}
else {
puts("fdatasync ASYNC: ok");
success_count++;
}
fs.fsync(fd, function(err) {
if(err) {
got_error = true;
}
else {
puts("fsync ASYNC: ok");
success_count++;
}
});
});
}
}
catch(e) {
got_error = true;
}
});
process.addListener("exit", function () {
assert.equal(4, success_count);
assert.equal(false, got_error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment