1 |
package manta.runtime; |
package gnu.java.nio; |
2 |
|
|
3 |
import java.io.*; |
import java.io.*; |
4 |
import java.nio.*; |
import java.nio.*; |
7 |
|
|
8 |
public class FileChannelImpl extends FileChannel |
public class FileChannelImpl extends FileChannel |
9 |
{ |
{ |
10 |
long address; |
public long address, length; |
11 |
int fd; |
public int fd; |
12 |
MappedByteBuffer buf; |
public MappedByteBuffer buf; |
13 |
Object file_obj; // just to keep it live... |
public Object file_obj; // just to keep it live... |
14 |
|
|
15 |
FileChannelImpl(int fd, |
public FileChannelImpl(int fd, |
16 |
Object obj) |
Object obj) |
17 |
{ |
{ |
18 |
this.fd = fd; |
this.fd = fd; |
19 |
this.file_obj = obj; |
this.file_obj = obj; |
20 |
} |
} |
21 |
|
|
22 |
FileChannelImpl(FileDescriptor fd, |
public FileChannelImpl(FileDescriptor fd, |
23 |
Object obj) |
Object obj) |
24 |
{ |
{ |
25 |
this(fd.file_des, obj); |
//this(fd.getNativeFD(), obj); |
26 |
|
this(0, obj); |
27 |
|
|
28 |
|
System.err.println("we need to get the native file-des here !\n"); |
29 |
} |
} |
30 |
|
|
31 |
|
|
32 |
|
public boolean isOpen() |
33 |
|
{ |
34 |
|
// FIXME |
35 |
|
return fd != 0; |
36 |
|
} |
37 |
|
|
38 |
|
public void close() |
39 |
|
{ |
40 |
|
} |
41 |
|
|
42 |
public int read(java.nio.ByteBuffer dst) throws IOException |
public int read(java.nio.ByteBuffer dst) throws IOException |
43 |
{ |
{ |
51 |
return 0; |
return 0; |
52 |
} |
} |
53 |
|
|
54 |
public int write(java.nio.ByteBuffer[] srcs, |
public long write(java.nio.ByteBuffer[] srcs, |
55 |
int offset, |
int offset, |
56 |
int length) throws IOException |
int length) throws IOException |
57 |
{ |
{ |
59 |
return 0; |
return 0; |
60 |
} |
} |
61 |
|
|
62 |
static MantaNative long nio_mmap_file(int fd, |
static native long nio_mmap_file(int fd, |
63 |
long pos, |
long pos, |
64 |
int size, |
int size, |
65 |
int mode); |
int mode); |
66 |
|
|
67 |
static MantaNative void nio_unmmap_file(int fd, |
static native void nio_unmmap_file(int fd, |
68 |
long pos, |
long pos, |
69 |
int size); |
int size); |
70 |
|
|
79 |
buf = new MappedByteFileBuffer(this); |
buf = new MappedByteFileBuffer(this); |
80 |
return buf; |
return buf; |
81 |
} |
} |
82 |
|
|
83 |
|
static MappedByteBuffer create_direct_mapped_buffer(long address, |
84 |
|
long length) |
85 |
|
{ |
86 |
|
FileChannelImpl ch = new FileChannelImpl(-1, null); |
87 |
|
|
88 |
|
ch.address = address; |
89 |
|
ch.length = length; |
90 |
|
|
91 |
|
ch.buf = new MappedByteFileBuffer(ch); |
92 |
|
return ch.buf; |
93 |
|
} |
94 |
} |
} |
95 |
|
|