Search in sources :

Example 31 with FileTime

use of java.nio.file.attribute.FileTime in project sonarqube by SonarSource.

the class GlobalTempFolderProviderTest method setFileCreationDate.

private void setFileCreationDate(File f, long time) throws IOException {
    BasicFileAttributeView attributes = Files.getFileAttributeView(f.toPath(), BasicFileAttributeView.class);
    FileTime creationTime = FileTime.fromMillis(time);
    attributes.setTimes(creationTime, creationTime, creationTime);
}
Also used : BasicFileAttributeView(java.nio.file.attribute.BasicFileAttributeView) FileTime(java.nio.file.attribute.FileTime)

Example 32 with FileTime

use of java.nio.file.attribute.FileTime in project ratpack by ratpack.

the class ReloadableFileBackedFactory method refresh.

private void refresh() throws Exception {
    lock.lock();
    try {
        FileTime lastModifiedTime = Files.getLastModifiedTime(file);
        String content = Paths2.readText(file, StandardCharsets.UTF_8);
        if (lastModifiedTime.equals(lastModifiedHolder.get()) && content.equals(contentHolder.get())) {
            return;
        }
        T previous = delegateHolder.getAndSet(null);
        if (previous != null) {
            releaser.release(previous);
        }
        delegateHolder.set(producer.produce(file, content));
        this.lastModifiedHolder.set(lastModifiedTime);
        this.contentHolder.set(content);
    } finally {
        lock.unlock();
    }
}
Also used : FileTime(java.nio.file.attribute.FileTime)

Example 33 with FileTime

use of java.nio.file.attribute.FileTime in project syncany by syncany.

the class FileSystemAction method setLastModified.

protected void setLastModified(FileVersion reconstructedFileVersion, File reconstructedFilesAtFinalLocation) {
    try {
        FileTime newLastModifiedTime = FileTime.fromMillis(reconstructedFileVersion.getLastModified().getTime());
        Files.setLastModifiedTime(reconstructedFilesAtFinalLocation.toPath(), newLastModifiedTime);
    } catch (IOException e) {
        logger.log(Level.WARNING, "Warning: Could not set last modified date for file " + reconstructedFilesAtFinalLocation + "; Ignoring error.", e);
    }
}
Also used : FileTime(java.nio.file.attribute.FileTime) IOException(java.io.IOException)

Example 34 with FileTime

use of java.nio.file.attribute.FileTime in project sakuli by ConSol.

the class TestSuiteHelperTest method testNotModifyFiles.

@Test
public void testNotModifyFiles() throws Exception {
    Path path = Paths.get("temp-testsuite.suite");
    try {
        String source = "line1\r\nbla\r\n";
        FileUtils.writeStringToFile(path.toFile(), source);
        FileTime beforeTimeStamp = Files.getLastModifiedTime(path, LinkOption.NOFOLLOW_LINKS);
        Thread.sleep(1100);
        String result = TestSuiteHelper.prepareTestSuiteFile(path);
        assertEquals(source, result);
        FileTime afterTimeStamp = Files.getLastModifiedTime(path, LinkOption.NOFOLLOW_LINKS);
        assertEquals(beforeTimeStamp, afterTimeStamp);
    } finally {
        Files.deleteIfExists(path);
    }
}
Also used : Path(java.nio.file.Path) FileTime(java.nio.file.attribute.FileTime) Test(org.testng.annotations.Test)

Example 35 with FileTime

use of java.nio.file.attribute.FileTime in project jdk8u_jdk by JetBrains.

the class Basic method eq.

static void eq(Instant ins, long v2, TimeUnit u2) {
    FileTime t1 = FileTime.from(ins);
    FileTime t2 = FileTime.from(v2, u2);
    if (!t1.equals(t2))
        throw new RuntimeException("not equal");
    if (t1.hashCode() != t2.hashCode())
        throw new RuntimeException("hashCodes should be equal");
}
Also used : FileTime(java.nio.file.attribute.FileTime)

Aggregations

FileTime (java.nio.file.attribute.FileTime)40 Path (java.nio.file.Path)11 File (java.io.File)7 Test (org.junit.Test)7 Test (org.testng.annotations.Test)7 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)6 IOException (java.io.IOException)5 SegmentMetadataImpl (com.linkedin.pinot.core.segment.index.SegmentMetadataImpl)4 BasicFileAttributeView (java.nio.file.attribute.BasicFileAttributeView)3 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)2 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)2 SegmentV1V2ToV3FormatConverter (com.linkedin.pinot.core.segment.index.converter.SegmentV1V2ToV3FormatConverter)2 FileNotFoundException (java.io.FileNotFoundException)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 NoSuchFileException (java.nio.file.NoSuchFileException)2 Date (java.util.Date)2 BuildTarget (com.facebook.buck.model.BuildTarget)1 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1