本文整理匯總了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();
});
});