Commit ca1d829f by Michael Koch Committed by Michael Koch

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.

From-SVN: r76421
parent 0e707673
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
(sync): Moved around, added javadoc.
(valid): Likewise.
(open): Likewise.
......
......@@ -208,6 +208,10 @@ public final class FileDescriptor
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
{
......
......@@ -136,3 +136,24 @@ java::io::FileDescriptor::available (void)
{
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"));
}
......@@ -13,6 +13,7 @@ details. */
#include "posix.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
......@@ -420,3 +421,47 @@ java::io::FileDescriptor::available (void)
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)));
}
......@@ -350,3 +350,24 @@ java::io::FileDescriptor::available(void)
// 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"));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment