cleanExpiredLog method
清除过期log file:文件
Implementation
// directory:文件夹
// link:链接文件
// notFound:未知
void cleanExpiredLog(String logPath, int retentionTime) async {
final curTime = DateTimeUtils.getNowDateMs();
// 根据路径字符串创建目录对象
// recursive是否递归列出子目录 followLinks是否允许link
await for (final file in Directory(logPath).list(followLinks: false)) {
final FileSystemEntityType type = FileSystemEntity.typeSync(file.path);
if (type == FileSystemEntityType.file) {
final lastModified = (file as File).lastModifiedSync();
if (curTime - lastModified.millisecondsSinceEpoch > retentionTime) {
await file.delete();
}
}
}
}