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);
}
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();
}
}
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);
}
}
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);
}
}
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");
}
Aggregations