org.cryptomator.jfuse.mac.TimeSpecImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfuse-mac Show documentation
Show all versions of jfuse-mac Show documentation
Java FUSE bindings for macOS x86_64 and arm64
package org.cryptomator.jfuse.mac;
import org.cryptomator.jfuse.api.TimeSpec;
import org.cryptomator.jfuse.mac.extr.stat_h;
import org.cryptomator.jfuse.mac.extr.timespec;
import java.lang.foreign.MemorySegment;
import java.time.Instant;
record TimeSpecImpl(MemorySegment segment) implements TimeSpec {
@Override
public boolean isUtimeOmit() {
var nanos = timespec.tv_nsec$get(segment);
return stat_h.UTIME_OMIT() == nanos;
}
@Override
public boolean isUtimeNow() {
var nanos = timespec.tv_nsec$get(segment);
return stat_h.UTIME_NOW() == nanos;
}
@Override
public void set(Instant newValue) {
timespec.tv_sec$set(segment, newValue.getEpochSecond());
timespec.tv_nsec$set(segment, newValue.getNano());
}
@Override
public Instant get() {
var seconds = timespec.tv_sec$get(segment);
var nanos = timespec.tv_nsec$get(segment);
return Instant.ofEpochSecond(seconds, nanos);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy