main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
615 bytes
|
Rev | Line | |
---|
[d24f17c] | 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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.