} else if( os.toLowerCase().startsWith("windows") ) {
// We will gracefully fall back to default JDK file sync behavior
// if the JNA library is not in the path, and we can't set the
// FileDescriptor.fd field accessible.
try {
final Kernel32Library lib = getKernel32Library();
return new SyncStrategy() {
public void sync(FileDescriptor fd) throws IOException {
fd.sync();
}
public void hardlink(File source, File target) throws IOException {
int rc = lib.CreateHardLink(target.getCanonicalPath(), source.getCanonicalPath(), 0);
if( rc == 0 ){
throw new IOException("Hard link failed with result code="+lib.GetLastError());
}
}
};
} catch (Throwable ignore) {
// Perhaps we should issue a warning here so folks know that
// the disk syncs are not going to be of very good quality.
}
}
// We will gracefully fall back to default JDK file sync behavior
// if the JNA library is not in the path, and we can't set the
// FileDescriptor.fd field accessible.
try {
final CLibrary lib = getCLibrary();
return new SyncStrategy() {
public void sync(FileDescriptor fd) throws IOException {
fd.sync();
}
public void hardlink(File source, File target) throws IOException {
int rc = lib.link(source.getCanonicalPath(), target.getCanonicalPath());
if( rc != 0 ){
throw new IOException("Hard link failed with result code="+rc);
}
}
};