aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/jdisc/state/FileWrapper.java
blob: b0154a688671059e697021f9d2211385b1c363a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright Vespa.ai. 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);
    }

}