Issue #86: Added support for Unix Timestamps
Co-authored-by: David Humphrey <david.humphrey@senecacollege.ca>
This commit is contained in:
parent
83bd64fd58
commit
443b582038
13
README.md
13
README.md
|
@ -445,9 +445,12 @@ Callback gets `(error, stats)`, where `stats` is an object with the following pr
|
|||
name: <string> // the entry's name (basename)
|
||||
size: <number> // file size in bytes
|
||||
nlinks: <number> // number of links
|
||||
atime: <number> // last access time
|
||||
mtime: <number> // last modified time
|
||||
ctime: <number> // creation time
|
||||
atime: <date> // last access time as JS Date Object
|
||||
mtime: <date> // last modified time as JS Date Object
|
||||
ctime: <date> // creation time as JS Date Object
|
||||
atimeMs: <number> // last access time as Unix Timestamp
|
||||
mtimeMs: <number> // last modified time as Unix Timestamp
|
||||
ctimeMs: <number> // creation time as Unix Timestamp
|
||||
type: <string> // file type (FILE, DIRECTORY, SYMLINK),
|
||||
gid: <number> // group name
|
||||
uid: <number> // owner name
|
||||
|
@ -796,7 +799,7 @@ fs.open('/myfile', 'w', function(err, fd) {
|
|||
|
||||
#### fs.utimes(path, atime, mtime, callback)<a name="utimes"></a>
|
||||
|
||||
Changes the file timestamps for the file given at path `path`. Asynchronous [utimes(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html). Callback gets no additional arguments. Both `atime` (access time) and `mtime` (modified time) arguments should be a JavaScript Date.
|
||||
Changes the file timestamps for the file given at path `path`. Asynchronous [utimes(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html). Callback gets no additional arguments. Both `atime` (access time) and `mtime` (modified time) arguments should be a JavaScript Date or Number.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -810,7 +813,7 @@ fs.utimes('/myfile.txt', now, now, function(err) {
|
|||
|
||||
#### fs.futimes(fd, atime, mtime, callback)<a name="futimes"></a>
|
||||
|
||||
Changes the file timestamps for the open file represented by the file descriptor `fd`. Asynchronous [utimes(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html). Callback gets no additional arguments. Both `atime` (access time) and `mtime` (modified time) arguments should be a JavaScript Date.
|
||||
Changes the file timestamps for the open file represented by the file descriptor `fd`. Asynchronous [utimes(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html). Callback gets no additional arguments. Both `atime` (access time) and `mtime` (modified time) arguments should be a JavaScript Date or Number.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -1774,6 +1774,15 @@
|
|||
"type-detect": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"chai-datetime": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/chai-datetime/-/chai-datetime-1.5.0.tgz",
|
||||
"integrity": "sha1-N0LxiwJMdbdqK37uKRZiMkRnWWw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chai": ">1.9.0"
|
||||
}
|
||||
},
|
||||
"chalk": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz",
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.2",
|
||||
"chai-datetime": "^1.5.0",
|
||||
"eslint": "^5.0.1",
|
||||
"karma": "^3.0.0",
|
||||
"karma-chai": "^0.1.0",
|
||||
|
|
|
@ -2157,20 +2157,29 @@ function readdir(fs, context, path, callback) {
|
|||
read_directory(context, path, callback);
|
||||
}
|
||||
|
||||
function toUnixTimestamp(time) {
|
||||
if (typeof time === 'number') {
|
||||
return time;
|
||||
}
|
||||
if (typeof time === 'object' && typeof time.getTime === 'function') {
|
||||
return time.getTime() / 1000;
|
||||
}
|
||||
}
|
||||
|
||||
function utimes(fs, context, path, atime, mtime, callback) {
|
||||
if(!pathCheck(path, callback)) return;
|
||||
|
||||
var currentTime = Date.now();
|
||||
atime = (atime) ? atime : currentTime;
|
||||
mtime = (mtime) ? mtime : currentTime;
|
||||
atime = (atime) ? toUnixTimestamp(atime) : toUnixTimestamp(currentTime);
|
||||
mtime = (mtime) ? toUnixTimestamp(mtime) : toUnixTimestamp(currentTime);
|
||||
|
||||
utimes_file(context, path, atime, mtime, callback);
|
||||
}
|
||||
|
||||
function futimes(fs, context, fd, atime, mtime, callback) {
|
||||
var currentTime = Date.now();
|
||||
atime = (atime) ? atime : currentTime;
|
||||
mtime = (mtime) ? mtime : currentTime;
|
||||
atime = (atime) ? toUnixTimestamp(atime) : toUnixTimestamp(currentTime);
|
||||
mtime = (mtime) ? toUnixTimestamp(mtime) : toUnixTimestamp(currentTime);
|
||||
|
||||
var ofd = fs.openFiles[fd];
|
||||
if(!ofd) {
|
||||
|
|
16
src/stats.js
16
src/stats.js
|
@ -1,15 +1,25 @@
|
|||
var Constants = require('./constants.js');
|
||||
var Path = require('./path.js');
|
||||
|
||||
// https://github.com/nodejs/node/blob/4f1297f259b09d129ac01afbd4c674263b7ac124/lib/internal/fs/utils.js#L231
|
||||
function dateFromNumeric(num) {
|
||||
return new Date(Number(num) * 1000);
|
||||
}
|
||||
|
||||
function Stats(path, fileNode, devName) {
|
||||
this.dev = devName;
|
||||
this.node = fileNode.id;
|
||||
this.type = fileNode.type;
|
||||
this.size = fileNode.size;
|
||||
this.nlinks = fileNode.nlinks;
|
||||
this.atime = fileNode.atime;
|
||||
this.mtime = fileNode.mtime;
|
||||
this.ctime = fileNode.ctime;
|
||||
// Date objects
|
||||
this.atime = dateFromNumeric(fileNode.atime);
|
||||
this.mtime = dateFromNumeric(fileNode.mtime);
|
||||
this.ctime = dateFromNumeric(fileNode.ctime);
|
||||
// Unix timestamp Numbers
|
||||
this.atimeMs = fileNode.atime;
|
||||
this.mtimeMs = fileNode.mtime;
|
||||
this.ctimeMs = fileNode.ctime;
|
||||
this.version = fileNode.version;
|
||||
this.mode = fileNode.mode;
|
||||
this.uid = fileNode.uid;
|
||||
|
|
|
@ -32,15 +32,38 @@ describe('fs.stat', function() {
|
|||
expect(result['dev']).to.equal(fs.name);
|
||||
expect(result['size']).to.be.a('number');
|
||||
expect(result['nlinks']).to.be.a('number');
|
||||
expect(result['atime']).to.be.a('number');
|
||||
expect(result['mtime']).to.be.a('number');
|
||||
expect(result['ctime']).to.be.a('number');
|
||||
expect(result['atime']).to.be.a('date');
|
||||
expect(result['mtime']).to.be.a('date');
|
||||
expect(result['ctime']).to.be.a('date');
|
||||
expect(result['atimeMs']).to.be.a('number');
|
||||
expect(result['mtimeMs']).to.be.a('number');
|
||||
expect(result['ctimeMs']).to.be.a('number');
|
||||
expect(result['type']).to.equal('DIRECTORY');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a stat object with equal Date and Unix Timestamps', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.stat('/', function(error, result) {
|
||||
expect(error).not.to.exist;
|
||||
expect(result).to.exist;
|
||||
|
||||
expect(result['atime']).to.be.a('date');
|
||||
expect(result['mtime']).to.be.a('date');
|
||||
expect(result['ctime']).to.be.a('date');
|
||||
|
||||
expect(result.atime.getTime()/1000).to.equal(result.atimeMs);
|
||||
expect(result.mtime.getTime()/1000).to.equal(result.mtimeMs);
|
||||
expect(result.ctime.getTime()/1000).to.equal(result.ctimeMs);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should follow symbolic links and return a stat object for the resulting path', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
|
@ -82,9 +105,12 @@ describe('fs.stat', function() {
|
|||
expect(result['dev']).to.equal(fs.name);
|
||||
expect(result['size']).to.be.a('number');
|
||||
expect(result['nlinks']).to.be.a('number');
|
||||
expect(result['atime']).to.be.a('number');
|
||||
expect(result['mtime']).to.be.a('number');
|
||||
expect(result['ctime']).to.be.a('number');
|
||||
expect(result['atime']).to.be.a('date');
|
||||
expect(result['mtime']).to.be.a('date');
|
||||
expect(result['ctime']).to.be.a('date');
|
||||
expect(result['atimeMs']).to.be.a('number');
|
||||
expect(result['mtimeMs']).to.be.a('number');
|
||||
expect(result['ctimeMs']).to.be.a('number');
|
||||
expect(result['type']).to.equal('FILE');
|
||||
|
||||
done();
|
||||
|
@ -117,9 +143,12 @@ describe('fs.stat', function() {
|
|||
expect(result.dev).to.equal(fs.name);
|
||||
expect(result.size).to.be.a('number');
|
||||
expect(result.nlinks).to.be.a('number');
|
||||
expect(result.atime).to.be.a('number');
|
||||
expect(result.mtime).to.be.a('number');
|
||||
expect(result.ctime).to.be.a('number');
|
||||
expect(result['atime']).to.be.a('date');
|
||||
expect(result['mtime']).to.be.a('date');
|
||||
expect(result['ctime']).to.be.a('date');
|
||||
expect(result['atimeMs']).to.be.a('number');
|
||||
expect(result['mtimeMs']).to.be.a('number');
|
||||
expect(result['ctimeMs']).to.be.a('number');
|
||||
expect(result.isDirectory()).to.be.true;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
var util = require('../lib/test-utils.js');
|
||||
var expect = require('chai').expect;
|
||||
var chai = require('chai');
|
||||
chai.use(require('chai-datetime'));
|
||||
var expect = chai.expect;
|
||||
|
||||
describe('fs.utimes', function() {
|
||||
beforeEach(util.setup);
|
||||
|
@ -78,7 +80,28 @@ describe('fs.utimes', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should change atime and mtime of a file path', function(done) {
|
||||
it('should change atime and mtime of a file path with Date', function(done) {
|
||||
var fs = util.fs();
|
||||
var atime = new Date('1 Oct 2000 15:33:22');
|
||||
var mtime = new Date('30 Sep 2000 06:43:54');
|
||||
|
||||
fs.writeFile('/testfile', '', function (error) {
|
||||
if (error) throw error;
|
||||
|
||||
fs.utimes('/testfile', atime, mtime, function (error) {
|
||||
expect(error).not.to.exist;
|
||||
|
||||
fs.stat('/testfile', function (error, stat) {
|
||||
expect(error).not.to.exist;
|
||||
expect(stat.atime).to.equalDate(atime);
|
||||
expect(stat.mtime).to.equalDate(mtime);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should change atime and mtime of a file path with Unix timestamp', function(done) {
|
||||
var fs = util.fs();
|
||||
var atime = Date.parse('1 Oct 2000 15:33:22');
|
||||
var mtime = Date.parse('30 Sep 2000 06:43:54');
|
||||
|
@ -91,7 +114,8 @@ describe('fs.utimes', function() {
|
|||
|
||||
fs.stat('/testfile', function (error, stat) {
|
||||
expect(error).not.to.exist;
|
||||
expect(stat.mtime).to.equal(mtime);
|
||||
expect(stat.atimeMs).to.equal(atime);
|
||||
expect(stat.mtimeMs).to.equal(mtime);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -111,7 +135,7 @@ describe('fs.utimes', function() {
|
|||
|
||||
fs.stat('/testdir', function (error, stat) {
|
||||
expect(error).not.to.exist;
|
||||
expect(stat.mtime).to.equal(mtime);
|
||||
expect(stat.mtimeMs).to.equal(mtime);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -133,8 +157,8 @@ describe('fs.utimes', function() {
|
|||
// Note: testing estimation as time may differ by a couple of milliseconds
|
||||
// This number should be increased if tests are on slow systems
|
||||
var delta = Date.now() - then;
|
||||
expect(then - stat.atime).to.be.at.most(delta);
|
||||
expect(then - stat.mtime).to.be.at.most(delta);
|
||||
expect(then - stat.atimeMs).to.be.at.most(delta);
|
||||
expect(then - stat.mtimeMs).to.be.at.most(delta);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -196,7 +220,7 @@ describe('fs.promises.utimes', function () {
|
|||
.writeFile('/testfile', '')
|
||||
.then(() => fs.utimes('/testfile', atime, mtime))
|
||||
.then(() => fs.stat('/testfile'))
|
||||
.then(stat => expect(stat.mtime).to.equal(mtime));
|
||||
.then(stat => expect(stat.mtimeMs).to.equal(mtime));
|
||||
});
|
||||
|
||||
it('should update atime and mtime of directory path', function () {
|
||||
|
@ -209,7 +233,7 @@ describe('fs.promises.utimes', function () {
|
|||
.then(() => fs.utimes('/testdir', atime, mtime))
|
||||
.then(() => fs.stat('/testdir'))
|
||||
.then(stat => {
|
||||
expect(stat.mtime).to.equal(mtime);
|
||||
expect(stat.mtimeMs).to.equal(mtime);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -228,8 +252,8 @@ describe('fs.promises.utimes', function () {
|
|||
// Note: testing estimation as time may differ by a couple of milliseconds
|
||||
// This number should be increased if tests are on slow systems
|
||||
var delta = Date.now() - t1;
|
||||
expect(t1 - stat.atime).to.be.at.most(delta);
|
||||
expect(t1 - stat.mtime).to.be.at.most(delta);
|
||||
expect(t1 - stat.atimeMs).to.be.at.most(delta);
|
||||
expect(t1 - stat.mtimeMs).to.be.at.most(delta);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('FileSystemShell.ls', function() {
|
|||
expect(item0.name).to.equal('file');
|
||||
expect(item0.nlinks).to.equal(1);
|
||||
expect(item0.size).to.equal(1);
|
||||
expect(item0.mtime).to.be.a('number');
|
||||
expect(item0.mtime).to.be.a('date');
|
||||
expect(item0.isFile()).to.be.true;
|
||||
expect(item0.contents).not.to.exist;
|
||||
|
||||
|
@ -50,7 +50,7 @@ describe('FileSystemShell.ls', function() {
|
|||
expect(item1.name).to.equal('file2');
|
||||
expect(item1.nlinks).to.equal(1);
|
||||
expect(item1.size).to.equal(2);
|
||||
expect(item1.mtime).to.be.a('number');
|
||||
expect(item1.mtime).to.be.a('date');
|
||||
expect(item1.isFile()).to.be.true;
|
||||
expect(item0.contents).not.to.exist;
|
||||
|
||||
|
@ -87,7 +87,7 @@ describe('FileSystemShell.ls', function() {
|
|||
case 'dir2':
|
||||
expect(item.nlinks).to.equal(1);
|
||||
expect(item.size).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('date');
|
||||
expect(item.isDirectory()).to.be.true;
|
||||
expect(item.contents).not.to.exist;
|
||||
break;
|
||||
|
@ -95,7 +95,7 @@ describe('FileSystemShell.ls', function() {
|
|||
case 'file2':
|
||||
expect(item.nlinks).to.equal(1);
|
||||
expect(item.size).to.equal(1);
|
||||
expect(item.mtime).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('date');
|
||||
expect(item.isFile()).to.be.true;
|
||||
expect(item.contents).not.to.exist;
|
||||
break;
|
||||
|
@ -146,7 +146,7 @@ describe('FileSystemShell.ls', function() {
|
|||
case 'dir2':
|
||||
expect(item.nlinks).to.equal(1);
|
||||
expect(item.size).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('date');
|
||||
expect(item.isDirectory()).to.be.true;
|
||||
expect(item.contents).to.exist;
|
||||
expect(item.contents.length).to.equal(1);
|
||||
|
@ -154,7 +154,7 @@ describe('FileSystemShell.ls', function() {
|
|||
expect(contents0.name).to.equal('file');
|
||||
expect(contents0.nlinks).to.equal(1);
|
||||
expect(contents0.size).to.equal(1);
|
||||
expect(contents0.mtime).to.be.a('number');
|
||||
expect(contents0.mtime).to.be.a('date');
|
||||
expect(contents0.isFile()).to.be.true;
|
||||
expect(contents0.contents).not.to.exist;
|
||||
break;
|
||||
|
@ -162,7 +162,7 @@ describe('FileSystemShell.ls', function() {
|
|||
case 'file2':
|
||||
expect(item.nlinks).to.equal(1);
|
||||
expect(item.size).to.equal(1);
|
||||
expect(item.mtime).to.be.a('number');
|
||||
expect(item.mtime).to.be.a('date');
|
||||
expect(item.isFile()).to.be.true;
|
||||
expect(item.contents).not.to.exist;
|
||||
break;
|
||||
|
|
|
@ -4,7 +4,7 @@ var expect = require('chai').expect;
|
|||
function getTimes(fs, path, callback) {
|
||||
fs.stat(path, function(error, stats) {
|
||||
if(error) throw error;
|
||||
callback({mtime: stats.mtime, atime: stats.atime});
|
||||
callback({mtime: stats.mtimeMs, atime: stats.atimeMs});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ describe('node times (atime, mtime, ctime) with mount flags', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(fs, newfilename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -73,9 +73,9 @@ describe('node times (atime, mtime, ctime) with mount flags', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(fs, filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -93,9 +93,9 @@ describe('node times (atime, mtime, ctime) with mount flags', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(fs, filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var util = require('../lib/test-utils.js');
|
||||
var expect = require('chai').expect;
|
||||
|
||||
describe('node times (atime, mtime, ctime)', function() {
|
||||
describe('node times (atime, mtime, ctimeMs)', function() {
|
||||
beforeEach(util.setup);
|
||||
afterEach(util.cleanup);
|
||||
|
||||
|
@ -41,9 +41,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(newfilename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -61,9 +61,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -84,9 +84,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
|
||||
fs.close(fd, done);
|
||||
});
|
||||
|
@ -105,9 +105,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
fs.stat(filename, function(error, stats2) {
|
||||
if(error) throw error;
|
||||
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -126,9 +126,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
fs.fstat(fd, function(error, stats2) {
|
||||
if(error) throw error;
|
||||
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
|
||||
fs.close(fd, done);
|
||||
});
|
||||
|
@ -148,9 +148,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
fs.lstat('/link', function(error, stats2) {
|
||||
if(error) throw error;
|
||||
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -170,9 +170,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
fs.stat(filename, function(error, stats2) {
|
||||
if(error) throw error;
|
||||
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -189,9 +189,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -208,9 +208,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -231,9 +231,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
expect(contents).to.equal(filename);
|
||||
|
||||
stat('/link', function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -251,9 +251,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(dirname, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -274,9 +274,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat('/', function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -295,9 +295,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat('/', function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -317,9 +317,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -337,9 +337,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
|
||||
fs.close(fd, done);
|
||||
});
|
||||
|
@ -369,9 +369,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat('/myfile', function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -410,9 +410,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat('/myfile', function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -435,9 +435,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
expect(data).to.exist;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -454,9 +454,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -473,9 +473,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.be.at.least(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.be.at.least(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -492,9 +492,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -514,9 +514,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -538,9 +538,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
expect(value).to.equal('data');
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -565,9 +565,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
expect(value).to.equal('data');
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.equal(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.equal(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.equal(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.equal(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -589,9 +589,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -615,9 +615,9 @@ describe('node times (atime, mtime, ctime)', function() {
|
|||
if(error) throw error;
|
||||
|
||||
stat(filename, function(stats2) {
|
||||
expect(stats2.ctime).to.be.at.least(stats1.ctime);
|
||||
expect(stats2.mtime).to.equal(stats1.mtime);
|
||||
expect(stats2.atime).to.be.at.least(stats1.atime);
|
||||
expect(stats2.ctimeMs).to.be.at.least(stats1.ctimeMs);
|
||||
expect(stats2.mtimeMs).to.equal(stats1.mtimeMs);
|
||||
expect(stats2.atimeMs).to.be.at.least(stats1.atimeMs);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue