/ cloudformation-templates / node_modules / aws-cdk / node_modules / fs-extra / lib / util / utimes.js
utimes.js
1 'use strict' 2 3 const fs = require('graceful-fs') 4 5 function utimesMillis (path, atime, mtime, callback) { 6 // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback) 7 fs.open(path, 'r+', (err, fd) => { 8 if (err) return callback(err) 9 fs.futimes(fd, atime, mtime, futimesErr => { 10 fs.close(fd, closeErr => { 11 if (callback) callback(futimesErr || closeErr) 12 }) 13 }) 14 }) 15 } 16 17 function utimesMillisSync (path, atime, mtime) { 18 const fd = fs.openSync(path, 'r+') 19 fs.futimesSync(fd, atime, mtime) 20 return fs.closeSync(fd) 21 } 22 23 module.exports = { 24 utimesMillis, 25 utimesMillisSync 26 }