mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-23 00:51:00 +08:00
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
This commit is contained in:
parent
0e707673d2
commit
ca1d829f31
@ -1,3 +1,22 @@
|
||||
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
|
||||
|
@ -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"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user