UNPKG

615 BJavaScriptView Raw
1'use strict'
2
3const fs = require('graceful-fs')
4
5function 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
17function utimesMillisSync (path, atime, mtime) {
18 const fd = fs.openSync(path, 'r+')
19 fs.futimesSync(fd, atime, mtime)
20 return fs.closeSync(fd)
21}
22
23module.exports = {
24 utimesMillis,
25 utimesMillisSync
26}