2010-12-05 00:20:34 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-03-08 19:02:19 +01:00
|
|
|
var fs = require('fs');
|
2009-06-29 14:11:26 +02:00
|
|
|
var got_error = false;
|
2009-09-11 13:41:47 +02:00
|
|
|
var success_count = 0;
|
2009-06-29 14:11:26 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
fs.stat('.', function(err, stats) {
|
2010-02-20 01:02:30 +01:00
|
|
|
if (err) {
|
|
|
|
got_error = true;
|
|
|
|
} else {
|
2010-10-12 01:09:02 +02:00
|
|
|
console.dir(stats);
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.ok(stats.mtime instanceof Date);
|
|
|
|
success_count++;
|
|
|
|
}
|
2009-06-29 14:11:26 +02:00
|
|
|
});
|
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
fs.lstat('.', function(err, stats) {
|
2010-02-22 05:10:23 +01:00
|
|
|
if (err) {
|
|
|
|
got_error = true;
|
|
|
|
} else {
|
2010-10-12 01:09:02 +02:00
|
|
|
console.dir(stats);
|
2010-02-22 05:10:23 +01:00
|
|
|
assert.ok(stats.mtime instanceof Date);
|
|
|
|
success_count++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-05-12 22:35:33 +02:00
|
|
|
// fstat
|
2010-12-05 20:15:30 +01:00
|
|
|
fs.open('.', 'r', undefined, function(err, fd) {
|
2010-05-12 22:35:33 +02:00
|
|
|
assert.ok(!err);
|
|
|
|
assert.ok(fd);
|
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
fs.fstat(fd, function(err, stats) {
|
2010-05-12 22:35:33 +02:00
|
|
|
if (err) {
|
|
|
|
got_error = true;
|
|
|
|
} else {
|
2010-10-12 01:09:02 +02:00
|
|
|
console.dir(stats);
|
2010-05-12 22:35:33 +02:00
|
|
|
assert.ok(stats.mtime instanceof Date);
|
|
|
|
success_count++;
|
|
|
|
fs.close(fd);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// fstatSync
|
2010-12-05 20:15:30 +01:00
|
|
|
fs.open('.', 'r', undefined, function(err, fd) {
|
2010-05-12 22:35:33 +02:00
|
|
|
var stats;
|
|
|
|
try {
|
|
|
|
stats = fs.fstatSync(fd);
|
|
|
|
} catch (err) {
|
|
|
|
got_error = true;
|
|
|
|
}
|
|
|
|
if (stats) {
|
2010-10-12 01:09:02 +02:00
|
|
|
console.dir(stats);
|
2010-05-12 22:35:33 +02:00
|
|
|
assert.ok(stats.mtime instanceof Date);
|
|
|
|
success_count++;
|
|
|
|
}
|
|
|
|
fs.close(fd);
|
|
|
|
});
|
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('stating: ' + __filename);
|
|
|
|
fs.stat(__filename, function(err, s) {
|
2010-02-20 01:02:30 +01:00
|
|
|
if (err) {
|
|
|
|
got_error = true;
|
|
|
|
} else {
|
2010-10-12 01:09:02 +02:00
|
|
|
console.dir(s);
|
2010-02-20 01:02:30 +01:00
|
|
|
success_count++;
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isDirectory: ' + JSON.stringify(s.isDirectory()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isDirectory());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isFile: ' + JSON.stringify(s.isFile()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(true, s.isFile());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isSocket: ' + JSON.stringify(s.isSocket()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isSocket());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isBlockDevice());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isCharacterDevice());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isFIFO: ' + JSON.stringify(s.isFIFO()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isFIFO());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink()));
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.equal(false, s.isSymbolicLink());
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-02-20 01:02:30 +01:00
|
|
|
assert.ok(s.mtime instanceof Date);
|
|
|
|
}
|
|
|
|
});
|
2009-09-11 13:41:47 +02:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
process.addListener('exit', function() {
|
2010-05-12 22:35:33 +02:00
|
|
|
assert.equal(5, success_count);
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(false, got_error);
|
2009-08-26 18:51:04 +02:00
|
|
|
});
|
2009-06-29 14:11:26 +02:00
|
|
|
|