From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../sdbcx/comp/hsqldb/NativeInputStreamHelper.java | 62 +++++++++ .../star/sdbcx/comp/hsqldb/NativeLibraries.java | 71 ++++++++++ .../comp/hsqldb/NativeOutputStreamHelper.java | 60 +++++++++ .../sdbcx/comp/hsqldb/NativeStorageAccess.java | 62 +++++++++ .../sun/star/sdbcx/comp/hsqldb/StorageAccess.java | 126 ++++++++++++++++++ .../star/sdbcx/comp/hsqldb/StorageFileAccess.java | 90 +++++++++++++ .../comp/hsqldb/StorageNativeInputStream.java | 34 +++++ .../comp/hsqldb/StorageNativeOutputStream.java | 145 +++++++++++++++++++++ 8 files changed, 650 insertions(+) create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java (limited to 'connectivity/com') diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java new file mode 100644 index 000000000..66b6f5489 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java @@ -0,0 +1,62 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeInputStreamHelper extends java.io.InputStream{ + private final String key; + private final String file; + private final StorageNativeInputStream in; + /** Creates a new instance of NativeInputStreamHelper */ + public NativeInputStreamHelper(String key,String _file) { + file = _file; + this.key = key; + in = new StorageNativeInputStream(key,file); + } + + @Override + public int read() throws java.io.IOException { + return in.read(key,file); + } + + @Override + public int read(byte[] b, int off, int len) throws java.io.IOException { + return in.read(key,file,b,off,len); + } + + @Override + public void close() throws java.io.IOException { + in.close(key,file); + } + + @Override + public long skip(long n) throws java.io.IOException { + return in.skip(key,file,n); + } + + @Override + public int available() throws java.io.IOException { + return in.available(key,file); + } + + @Override + public int read(byte[] b) throws java.io.IOException { + return in.read(key,file,b); + } + +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java new file mode 100644 index 000000000..e8ea8d44e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java @@ -0,0 +1,71 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package com.sun.star.sdbcx.comp.hsqldb; + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +final class NativeLibraries { + public static void load() { + if (System.getProperty( "os.name" ).startsWith("Windows")) { + loadLibrary("msvcr71"); + loadLibrary("sal3"); + loadLibrary("dbtoolsmi"); + } + loadLibrary("hsqldb"); + } + + private static void loadLibrary(String libname) { + // At least on macOS Tiger, System.loadLibrary("hsqldb2") does not + // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even + // though ".." is on the jar's Class-Path; however, the alternative + // code (needing Java 1.5, which is given for macOS Tiger) works + // there: + try { + System.loadLibrary(libname); + } catch (UnsatisfiedLinkError e) { + ClassLoader cl = NativeLibraries.class.getClassLoader(); + if (cl instanceof URLClassLoader) { + String sysname = System.mapLibraryName(libname); + // At least Oracle's 1.7.0_51 now maps to .dylib rather than + // .jnilib: + if (System.getProperty("os.name").startsWith("Mac") + && sysname.endsWith(".dylib")) + { + sysname + = sysname.substring( + 0, sysname.length() - "dylib".length()) + + "jnilib"; + } + URL url = ((URLClassLoader) cl).findResource(sysname); + if (url != null) { + try { + System.load(new File(url.toURI()).getAbsolutePath()); + } catch (Throwable t) { + throw new UnsatisfiedLinkError( + e.toString()+ " - " + t.toString()); + } + } + } + } + } + + private NativeLibraries() {} +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java new file mode 100644 index 000000000..6445f2413 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java @@ -0,0 +1,60 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeOutputStreamHelper extends java.io.OutputStream{ + + private final String key; + private final String file; + private final StorageNativeOutputStream out; + /** Creates a new instance of NativeOutputStreamHelper */ + public NativeOutputStreamHelper(String key,String _file) { + file = _file; + this.key = key; + out = new StorageNativeOutputStream(file,key); + } + + @Override + public void write(byte[] b, int off, int len) throws java.io.IOException{ + out.write(key,file,b, off, len); + } + + @Override + public void write(byte[] b) throws java.io.IOException{ + out.write(key,file,b); + } + + @Override + public void close() throws java.io.IOException{ + out.close(key,file); + } + + @Override + public void write(int b) throws java.io.IOException{ + out.write(key,file,b); + } + + @Override + public void flush() throws java.io.IOException{ + out.flush(key,file); + } + + public void sync() throws java.io.IOException{ + out.sync(key,file); + } +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java new file mode 100644 index 000000000..5a9bc8bb6 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java @@ -0,0 +1,62 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeStorageAccess { + static { NativeLibraries.load(); } + + public static final int READ = 1; + private static final int SEEKABLE = 2; + private static final int SEEKABLEREAD = 3; + public static final int WRITE = 4; + private static final int READWRITE = 7; + public static final int TRUNCATE = 8; + + /** Creates a new instance of StorageAccess */ + public NativeStorageAccess(String name,String _mode,Object key) throws java.io.IOException{ + try { + int mode = NativeStorageAccess.SEEKABLEREAD; + if ( _mode.equals("rw") ) + mode = NativeStorageAccess.READWRITE | NativeStorageAccess.SEEKABLE; + + openStream(name, (String)key, mode); + } catch(Exception ex1){ + java.io.IOException ex2 = new java.io.IOException(); + ex2.initCause(ex1); + throw ex2; + } + } + private native void openStream(String name,String key, int mode); + public native void close(String name,String key) throws java.io.IOException; + + public native long getFilePointer(String name,String key) throws java.io.IOException; + + public native long length(String name,String key) throws java.io.IOException; + + public native int read(String name,String key) throws java.io.IOException; + + public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException; + + + + public native void seek(String name,String key,long position) throws java.io.IOException; + + public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException; + + +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java new file mode 100644 index 000000000..6a53d110e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java @@ -0,0 +1,126 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package com.sun.star.sdbcx.comp.hsqldb; + +@SuppressWarnings("ucd") +public class StorageAccess implements org.hsqldb.lib.Storage { + String key; + String name; + boolean readonly; + NativeStorageAccess access; + /** Creates a new instance of StorageAccess */ + public StorageAccess(String name,Boolean readonly,Object key) throws java.io.IOException{ + this.key = (String)key; + this.name = name; + this.readonly = readonly.booleanValue(); + try { + access = new NativeStorageAccess(name, + this.readonly ? "r" : "rw" + ,key); + } catch(Exception ex1){ + java.io.IOException ex2 = new java.io.IOException(); + ex2.initCause(ex1); + throw ex2; + } + } + public void close() throws java.io.IOException{ + access.close(name,key); + } + + public long getFilePointer() throws java.io.IOException{ + return access.getFilePointer(name,key); + } + + public long length() throws java.io.IOException{ + return access.length(name,key); + } + + public int read() throws java.io.IOException{ + return access.read(name,key); + } + + public void read(byte[] b, int off, int len) throws java.io.IOException{ + access.read(name,key,b,off,len); + } + + // based on the same code that reads an int from the .data file in HSQLDB + public int readInt() throws java.io.IOException{ + byte [] tmp = new byte [4]; + + int count = access.read(name,key,tmp,0, 4); + + if (count != 4){ + throw new java.io.IOException(); + } + + count = 0; + int ch0 = tmp[count++] & 0xff; + int ch1 = tmp[count++] & 0xff; + int ch2 = tmp[count++] & 0xff; + int ch3 = tmp[count] & 0xff; + + return ((ch0 << 24) + (ch1 << 16) + (ch2 << 8) + (ch3)); + } + + public void seek(long position) throws java.io.IOException{ + access.seek(name,key,position); + } + + public void write(byte[] b, int offset, int length) throws java.io.IOException{ + access.write(name,key,b,offset,length); + } + + public void writeInt(int v) throws java.io.IOException{ + byte [] oneByte = new byte [4]; + oneByte[0] = (byte) ((v >>> 24) & 0xFF); + oneByte[1] = (byte) ((v >>> 16) & 0xFF); + oneByte[2] = (byte) ((v >>> 8) & 0xFF); + oneByte[3] = (byte) ((v >>> 0) & 0xFF); + + write(oneByte,0,4); + } + + public boolean isReadOnly() { + return readonly; + } + + @SuppressWarnings("cast") + public long readLong() throws java.io.IOException { + return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL); + } + + public boolean wasNio() { + return false; + } + + public void writeLong(long v) throws java.io.IOException { + byte [] oneByte = new byte [8]; + + oneByte[0] = (byte) ((v >>> 56) & 0xFF); + oneByte[1] = (byte) ((v >>> 48) & 0xFF); + oneByte[2] = (byte) ((v >>> 40) & 0xFF); + oneByte[3] = (byte) ((v >>> 32) & 0xFF); + oneByte[4] = (byte) ((v >>> 24) & 0xFF); + oneByte[5] = (byte) ((v >>> 16) & 0xFF); + oneByte[6] = (byte) ((v >>> 8) & 0xFF); + oneByte[7] = (byte) ((v >>> 0) & 0xFF); + + write(oneByte,0,8); + } +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java new file mode 100644 index 000000000..0dd640c4e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java @@ -0,0 +1,90 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +import org.hsqldb.lib.FileAccess; +import org.hsqldb.lib.FileSystemRuntimeException; + +@SuppressWarnings("ucd") +public class StorageFileAccess implements org.hsqldb.lib.FileAccess{ + static { NativeLibraries.load(); } + + String ds_name; + String key; + /** Creates a new instance of StorageFileAccess */ + public StorageFileAccess(Object key) throws java.lang.Exception{ + this.key = (String)key; + } + + public void createParentDirs(String filename) { + } + + public boolean isStreamElement(String elementName) { + return isStreamElement(key,elementName); + } + + public java.io.InputStream openInputStreamElement(String streamName) throws java.io.IOException { + return new NativeInputStreamHelper(key,streamName); + } + + public java.io.OutputStream openOutputStreamElement(String streamName) throws java.io.IOException { + return new NativeOutputStreamHelper(key,streamName); + } + + public void removeElement(String filename) throws java.util.NoSuchElementException { + try { + if ( isStreamElement(key,filename) ) + removeElement(key,filename); + } catch (java.io.IOException e) { + throw new FileSystemRuntimeException( e ); + } + } + + public void renameElement(String oldName, String newName) throws java.util.NoSuchElementException { + try { + if ( isStreamElement(key,oldName) ){ + removeElement(key,newName); + renameElement(key,oldName, newName); + } + } catch (java.io.IOException e) { + throw new FileSystemRuntimeException( e ); + } + } + + private static class FileSync implements FileAccess.FileSync + { + private final NativeOutputStreamHelper os; + private FileSync(NativeOutputStreamHelper _os) + { + os = _os; + } + public void sync() throws java.io.IOException + { + os.sync(); + } + } + + public FileAccess.FileSync getFileSync(java.io.OutputStream os) throws java.io.IOException + { + return new FileSync((NativeOutputStreamHelper)os); + } + + static native boolean isStreamElement(String key,String elementName); + static native void removeElement(String key,String filename) throws java.util.NoSuchElementException, java.io.IOException; + static native void renameElement(String key,String oldName, String newName) throws java.util.NoSuchElementException, java.io.IOException; +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java new file mode 100644 index 000000000..cf147c9b5 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java @@ -0,0 +1,34 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class StorageNativeInputStream { + static { NativeLibraries.load(); } + + /** Creates a new instance of StorageNativeInputStream */ + public StorageNativeInputStream(String key,String _file) { + openStream(key,_file, NativeStorageAccess.READ); + } + private native void openStream(String key,String name, int mode); + public native int read(String key,String name) throws java.io.IOException; + public native int read(String key,String name,byte[] b, int off, int len) throws java.io.IOException; + public native void close(String key,String name) throws java.io.IOException; + public native long skip(String key,String name,long n) throws java.io.IOException; + public native int available(String key,String name) throws java.io.IOException; + public native int read(String key,String name,byte[] b) throws java.io.IOException; +} diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java new file mode 100644 index 000000000..8cc6cb07d --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java @@ -0,0 +1,145 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class StorageNativeOutputStream { + static { NativeLibraries.load(); } + + /** Creates a new instance of StorageNativeOutputStream */ + public StorageNativeOutputStream(String _name, Object key) { + openStream(_name, (String)key, NativeStorageAccess.WRITE | NativeStorageAccess.TRUNCATE); + } + + private native void openStream(String name,String key, int mode); + /** + * Writes len bytes from the specified byte array + * starting at offset off to this output stream. + * The general contract for write(b, off, len) is that + * some of the bytes in the array b are written to the + * output stream in order; element b[off] is the first + * byte written and b[off+len-1] is the last byte written + * by this operation. + *

+ * The write method of OutputStream calls + * the write method of one argument on each of the bytes to be + * written out. Subclasses are encouraged to override this method and + * provide a more efficient implementation. + *

+ * If b is null, a + * NullPointerException is thrown. + *

+ * If off is negative, or len is negative, or + * off+len is greater than the length of the array + * b, then an IndexOutOfBoundsException is thrown. + * @param key The name of the data source. + * @param _file The name of the file to write to. + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @exception java.io.IOException if an I/O error occurs. In particular, + * an IOException is thrown if the output + * stream is closed. + */ + public native void write(String key,String _file,byte[] b, int off, int len) throws java.io.IOException; + + /** + * Writes b.length bytes from the specified byte array + * to this output stream. The general contract for write(b) + * is that it should have exactly the same effect as the call + * write(b, 0, b.length). + * + * @param b the data. + * @exception java.io.IOException if an I/O error occurs. + * @see java.io.OutputStream#write(byte[], int, int) + */ + public native void write(String key,String _file,byte[] b) throws java.io.IOException; + + /** + * Closes this output stream and releases any system resources + * associated with this stream. The general contract of close + * is that it closes the output stream. A closed stream cannot perform + * output operations and cannot be reopened. + *

+ * The close method of OutputStream does nothing. + * @param key The name of the data source. + * @param _file The name of the file to write to. + * + * @exception java.io.IOException if an I/O error occurs. + */ + public native void close(String key,String _file) throws java.io.IOException; + + /** + * Writes the specified byte to this output stream. The general + * contract for write is that one byte is written + * to the output stream. The byte to be written is the eight + * low-order bits of the argument b. The 24 + * high-order bits of b are ignored. + *

+ * Subclasses of OutputStream must provide an + * implementation for this method. + * + * @param key The name of the data source. + * @param _file The name of the file to write to. + * @param b the byte. + * @exception java.io.IOException if an I/O error occurs. In particular, + * an IOException may be thrown if the + * output stream has been closed. + */ + public native void write(String key,String _file,int b) throws java.io.IOException; + + /** + * Flushes this output stream and forces any buffered output bytes + * to be written out. The general contract of flush is + * that calling it is an indication that, if any bytes previously + * written have been buffered by the implementation of the output + * stream, such bytes should immediately be written to their + * intended destination. + *

+ * The flush method of OutputStream does nothing. + * @param key The name of the data source. + * @param _file The name of the file to write to. + * + * @exception java.io.IOException if an I/O error occurs. + */ + public native void flush(String key,String _file) throws java.io.IOException; + + /** + * Force all system buffers to synchronize with the underlying + * device. This method returns after all modified data and + * attributes have been written to the relevant device(s). + * + * sync is meant to be used by code that requires physical + * storage (such as a file) to be in a known state For + * example, a class that provided a simple transaction facility + * might use sync to ensure that all changes to a file caused + * by a given transaction were recorded on a storage medium. + * + * sync only affects buffers downstream. If + * any in-memory buffering is being done by the application (for + * example, by a BufferedOutputStream object), those buffers must + * be flushed (for example, by invoking + * OutputStream.flush) before that data will be affected by sync. + * + * @exception java.io.IOException + * Thrown when the buffers cannot be flushed, + * or because the system cannot guarantee that all the + * buffers have been synchronized with physical media. + */ + public native void sync(String key,String _file) throws java.io.IOException; + +} -- cgit v1.2.3