aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js
new file mode 100644
index 00000000..c99b010b
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/fs-extra/lib/util/utimes.js
@@ -0,0 +1,69 @@
+var fs = require('graceful-fs')
+var path = require('path')
+var os = require('os')
+
+// HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
+function hasMillisResSync () {
+ var tmpfile = path.join('millis-test-sync' + Date.now().toString() + Math.random().toString().slice(2))
+ tmpfile = path.join(os.tmpdir(), tmpfile)
+
+ // 550 millis past UNIX epoch
+ var d = new Date(1435410243862)
+ fs.writeFileSync(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141')
+ var fd = fs.openSync(tmpfile, 'r+')
+ fs.futimesSync(fd, d, d)
+ fs.closeSync(fd)
+ return fs.statSync(tmpfile).mtime > 1435410243000
+}
+
+function hasMillisRes (callback) {
+ var tmpfile = path.join('millis-test' + Date.now().toString() + Math.random().toString().slice(2))
+ tmpfile = path.join(os.tmpdir(), tmpfile)
+
+ // 550 millis past UNIX epoch
+ var d = new Date(1435410243862)
+ fs.writeFile(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141', function (err) {
+ if (err) return callback(err)
+ fs.open(tmpfile, 'r+', function (err, fd) {
+ if (err) return callback(err)
+ fs.futimes(fd, d, d, function (err) {
+ if (err) return callback(err)
+ fs.close(fd, function (err) {
+ if (err) return callback(err)
+ fs.stat(tmpfile, function (err, stats) {
+ if (err) return callback(err)
+ callback(null, stats.mtime > 1435410243000)
+ })
+ })
+ })
+ })
+ })
+}
+
+function timeRemoveMillis (timestamp) {
+ if (typeof timestamp === 'number') {
+ return Math.floor(timestamp / 1000) * 1000
+ } else if (timestamp instanceof Date) {
+ return new Date(Math.floor(timestamp.getTime() / 1000) * 1000)
+ } else {
+ throw new Error('fs-extra: timeRemoveMillis() unknown parameter type')
+ }
+}
+
+function utimesMillis (path, atime, mtime, callback) {
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
+ fs.open(path, 'r+', function (err, fd) {
+ if (err) return callback(err)
+ fs.futimes(fd, atime, mtime, function (err) {
+ if (err) return callback(err)
+ fs.close(fd, callback)
+ })
+ })
+}
+
+module.exports = {
+ hasMillisRes: hasMillisRes,
+ hasMillisResSync: hasMillisResSync,
+ timeRemoveMillis: timeRemoveMillis,
+ utimesMillis: utimesMillis
+}