summaryrefslogtreecommitdiffstats
path: root/libjava/java/nio/channels/FileChannelImpl.java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-23 14:37:09 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-23 14:37:09 +0000
commitc75d2847fb297e714ce596b2a5bdb59fb3b1bb11 (patch)
treec95fa932096fa9adbd0bc90d83618970a3f84572 /libjava/java/nio/channels/FileChannelImpl.java
parentd0ce7655692d3fd3784b97217cf8fc0e258df18f (diff)
downloadppe42-gcc-c75d2847fb297e714ce596b2a5bdb59fb3b1bb11.tar.gz
ppe42-gcc-c75d2847fb297e714ce596b2a5bdb59fb3b1bb11.zip
2004-01-23 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileLockImpl.java: Fixed filename in copyright. (released): Removed. (finalize): New method. * gnu/java/nio/natFileLockImpl.cc (releaseImpl): Implemented. * java/nio/channels/FileChannelImpl.java: Reworked imports. (lock): Implemented. (lockImpl): New method. (tryLock): Implemented. (tryLockImpl): New method. * java/nio/channels/natFileChannelImpl.cc (lockImpl): New method. (tryLockImpl): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76422 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/nio/channels/FileChannelImpl.java')
-rw-r--r--libjava/java/nio/channels/FileChannelImpl.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/libjava/java/nio/channels/FileChannelImpl.java b/libjava/java/nio/channels/FileChannelImpl.java
index 89ac11ad514..ea2526e7002 100644
--- a/libjava/java/nio/channels/FileChannelImpl.java
+++ b/libjava/java/nio/channels/FileChannelImpl.java
@@ -38,6 +38,9 @@ exception statement from your version. */
package java.nio.channels;
+import gnu.classpath.Configuration;
+import gnu.gcj.RawData;
+import gnu.java.nio.FileLockImpl;
import java.io.EOFException;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -47,8 +50,6 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.MappedByteBufferImpl;
-import gnu.classpath.Configuration;
-import gnu.gcj.RawData;
/**
* This file is not user visible !
@@ -354,8 +355,22 @@ public class FileChannelImpl extends FileChannel
file_obj instanceof FileInputStream)
throw new NonWritableChannelException ();
- throw new Error ("Not implemented");
+ boolean completed = false;
+
+ try
+ {
+ begin();
+ lockImpl(position, size, shared);
+ completed = true;
+ return new FileLockImpl(fd, this, position, size, shared);
+ }
+ finally
+ {
+ end(completed);
+ }
}
+
+ private native void lockImpl(long position, long size, boolean shared);
public FileLock tryLock (long position, long size, boolean shared)
throws IOException
@@ -367,9 +382,27 @@ public class FileChannelImpl extends FileChannel
if (!isOpen ())
throw new ClosedChannelException ();
- throw new Error ("Not implemented");
+ if (! tryLockImpl(position, size, shared))
+ return null;
+
+ boolean completed = false;
+
+ try
+ {
+ boolean lockable = tryLockImpl(position, size, shared);
+ completed = true;
+ return (lockable
+ ? new FileLockImpl(fd, this, position, size, shared)
+ : null);
+ }
+ finally
+ {
+ end(completed);
+ }
}
+ private native boolean tryLockImpl(long position, long size, boolean shared);
+
public long position ()
throws IOException
{
OpenPOWER on IntegriCloud