+2004-01-23 Michael Koch <konqueror@gmx.de>
+
+ * java/io/FileDescriptor.java
+ (lock): New method.
+ (tryLock): New method.
+ (unlock): New method.
+ * java/io/natFileDescriptorEcos.cc
+ (lock): New method.
+ (tryLock): New method.
+ (unlock): New method.
+ * java/io/natFileDescriptorPosix.cc
+ (lock): New method.
+ (tryLock): New method.
+ (unlock): New method.
+ * java/io/natFileDescriptorWin32.cc
+ (lock): New method.
+ (tryLock): New method.
+ (unlock): New method.
+
2004-01-23 Michael Koch <konqueror@gmx.de>
* java/io/FileDescriptor.java
native long getLength() throws IOException;
native void setLength(long pos) throws IOException;
+ native void lock(long pos, int len, boolean shared) throws IOException;
+ native boolean tryLock(long pos, int lent, boolean shared) throws IOException;
+ native void unlock(long pos, int len) throws IOException;
+
// When collected, close.
protected void finalize() throws Throwable
{
{
return 0;
}
+
+void
+java::io::FileDescriptor::lock (jlong pos, jint len, jboolean shared)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.lock() not implemented"));
+}
+
+jboolean
+java::io::FileDescriptor::tryLock (jlong pos, jint len, jboolean shared)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.tryLock() not implemented"));
+}
+
+void
+java::io::FileDescriptor::unlock (jlong pos, jint len)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.unlock() not implemented"));
+}
#include "posix.h"
#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
return 0;
#endif
}
+
+void
+java::io::FileDescriptor::lock (jlong pos, jint len, jboolean shared)
+{
+ struct flock lockdata;
+
+ lockdata.l_type = shared ? F_WRLCK : F_RDLCK;
+ lockdata.l_whence = SEEK_SET;
+ lockdata.l_start = pos;
+ lockdata.l_len = len;
+
+ if (::fcntl (fd, F_SETLK, &lockdata) == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+}
+
+jboolean
+java::io::FileDescriptor::tryLock (jlong pos, jint len, jboolean shared)
+{
+ struct flock lockdata;
+
+ lockdata.l_type = shared ? F_WRLCK : F_RDLCK;
+ lockdata.l_whence = SEEK_SET;
+ lockdata.l_start = pos;
+ lockdata.l_len = len;
+
+ if (::fcntl (fd, F_GETLK, &lockdata) == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+
+ return lockdata.l_type == F_UNLCK;
+}
+
+void
+java::io::FileDescriptor::unlock (jlong pos, jint len)
+{
+ struct flock lockdata;
+
+ lockdata.l_type = F_UNLCK;
+ lockdata.l_whence = SEEK_SET;
+ lockdata.l_start = pos;
+ lockdata.l_len = len;
+
+ if (::fcntl (fd, F_SETLK, &lockdata) == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+}
// FIXME:
return getLength() - getFilePointer();
}
+
+void
+java::io::FileDescriptor::lock (jlong pos, jint len, jboolean shared)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.lock() not implemented"));
+}
+
+jboolean
+java::io::FileDescriptor::tryLock (jlong pos, jint len, jboolean shared)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.tryLock() not implemented"));
+}
+
+void
+java::io::FileDescriptor::unlock (jlong pos, jint len)
+{
+ throw new IOException (JvNewStringLatin1
+ ("java.io.FileDescriptor.unlock() not implemented"));
+}