| 23 | import java.nio.channels.FileChannel; |
| 24 | |
| 25 | public class ElfFileChannel implements ElfByteChannel { |
| 26 | |
| 27 | private File mFile; |
| 28 | private FileInputStream mIs; |
| 29 | private FileChannel mFc; |
| 30 | |
| 31 | public ElfFileChannel(File file) throws IOException { |
| 32 | mFile = file; |
| 33 | openChannel(); |
| 34 | } |
| 35 | |
| 36 | public void openChannel() throws IOException { |
| 37 | mIs = new FileInputStream(mFile); |
| 38 | mFc = mIs.getChannel(); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public long position() throws IOException { |
| 43 | return mFc.position(); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public ElfByteChannel position(long newPosition) throws IOException { |
| 48 | mFc.position(newPosition); |
| 49 | return this; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public int read(ByteBuffer dst) throws IOException { |
| 54 | return mFc.read(dst); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public int read(ByteBuffer dst, long position) throws IOException { |
| 59 | return mFc.read(dst, position); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public long size() throws IOException { |
| 64 | return mFc.size(); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public ElfByteChannel truncate(long size) throws IOException { |
| 69 | mFc.truncate(size); |
| 70 | return this; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public int write(ByteBuffer src) throws IOException { |
| 75 | return mFc.write(src); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public void close() throws IOException { |
| 80 | mIs.close(); |
| 81 | } |
| 82 |
nothing calls this directly
no outgoing calls
no test coverage detected