MCPcopy Create free account
hub / github.com/L-JINBIN/ApkDataMultiplexing / RandomAccessDataImpl

Class RandomAccessDataImpl

src/bin/io/RandomAccessDataImpl.java:11–81  ·  view source on GitHub ↗

@author Bin

Source from the content-addressed store, hash-verified

9 * @author Bin
10 */
11class RandomAccessDataImpl implements RandomAccessData {
12 private final RandomAccessFile randomAccessFile;
13 private final File file;
14 private final String mode;
15
16 RandomAccessDataImpl(String path, String mode) throws FileNotFoundException {
17 this(new File(path), mode);
18 }
19
20 RandomAccessDataImpl(File file, String mode) throws FileNotFoundException {
21 this.file = file;
22 this.mode = mode;
23 this.randomAccessFile = new RandomAccessFile(file, mode);
24 }
25
26 @Override
27 public void seek(long pos) throws IOException {
28 randomAccessFile.seek(pos);
29 }
30
31 @Override
32 public int read(byte[] data, int off, int len) throws IOException {
33 return randomAccessFile.read(data, off, len);
34 }
35
36 @Override
37 public void write(byte[] data, int off, int len) throws IOException {
38 randomAccessFile.write(data, off, len);
39 }
40
41 @Override
42 public long length() throws IOException {
43 return randomAccessFile.length();
44 }
45
46 @Override
47 public void setLength(long newLength) throws IOException {
48 randomAccessFile.setLength(newLength);
49 }
50
51 @Override
52 public long position() throws IOException {
53 return randomAccessFile.getFilePointer();
54 }
55
56 @Override
57 public void sync() throws IOException {
58 randomAccessFile.getFD().sync();
59 }
60
61 @Override
62 public String getName() {
63 return file.getName();
64 }
65
66 @Override
67 public RandomAccessData getAnotherInSameParent(String name) throws IOException {
68 File another = new File(file.getParent(), name);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected