Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

utimes.js 615B

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