本文整理汇总了TypeScript中fs.utimes函数的典型用法代码示例。如果您正苦于以下问题:TypeScript utimes函数的具体用法?TypeScript utimes怎么用?TypeScript utimes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utimes函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
fs.stat(path, function(err: any, stats: fs.Stats): void {
if (err) {
// if we couldn't stat the
// specified file we should
// create it. Pass 'x' for
// the CREAT flag.
fs.open(path, 'wx', function(oerr: any, fd: number): void {
if (oerr) {
// now we're in trouble and
// we should try other files instead.
code = 1;
let msg = pathToScript + ': ' + oerr + '\n';
process.stderr.write(msg, finished);
}
// thats it - close the sucker.
fs.close(fd, finished);
});
} else {
// file exists - just use utimes,
// no need to open it.
fs.utimes(path, now, now, (uerr: any) => {
if (uerr) {
code = 1;
process.stderr.write('utimes: ' + uerr.message + '\n', finished);
return;
}
finished();
});
}
});
示例2: function
.pipe(through.obj(function (file, enc, cb) {
// https://github.com/webpack/watchpack/issues/25#issuecomment-287789288
var now = Date.now() / 1000;
var then = now - 10;
fs.utimes(file.path, then, then, function (err) { if (err) throw err });
cb(null, file);
}));
示例3: Date
return new Promise<void>((resolve, reject) => {
fs.utimes(path.resolve(extensionContext.extensionPath, ".."), new Date(Date.now()), new Date(Date.now()), (err) => {
if (err) {
reject(err);
}
resolve();
});
});