diff options
author | Ola Aunrønning <olaa@verizonmedia.com> | 2019-10-25 12:14:54 +0200 |
---|---|---|
committer | Ola Aunrønning <olaa@verizonmedia.com> | 2019-10-25 12:20:41 +0200 |
commit | 57fc9b631319ab522971c9272ecc6c84a9045343 (patch) | |
tree | 80f4308c27ca36ecf4976925b115c31e58de78b2 /container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java | |
parent | cce1d7872328f95c32567da873b061d974b5c862 (diff) |
Reuse same coredump/host-life gatherers
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java b/container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java new file mode 100644 index 00000000000..6e22e02eb5b --- /dev/null +++ b/container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java @@ -0,0 +1,27 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.container.jdisc.state; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Instant; +import java.util.stream.Stream; + +/** + * @author olaa + */ +public class FileWrapper { + + long getFileAgeInSeconds(Path path) throws IOException { + Instant lastModifiedTime = Files.getLastModifiedTime(path).toInstant(); + return Instant.now().getEpochSecond() - lastModifiedTime.getEpochSecond(); + } + + Stream<Path> walkTree(Path path) throws IOException { + return Files.walk(path); + } + + boolean isRegularFile(Path path) { + return Files.isRegularFile(path); + } +} |