@Implementation public static MemoryMappedFile mmapRO(String path) throws Throwable { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class) .newInstance("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(0L, 0L); ShadowMemoryMappedFile shadowMemoryMappedFile = Shadow.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class, Throwable.class) .newInstance("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
@Implementation public static MemoryMappedFile mmapRO(String path) throws Throwable { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class) .newInstance("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(0L, 0L); ShadowMemoryMappedFile shadowMemoryMappedFile = (ShadowMemoryMappedFile) ShadowExtractor.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class, Throwable.class) .newInstance("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
@Implementation public static MemoryMappedFile mmapRO(String path) throws Throwable { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class) .newInstance("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(0L, 0L); ShadowMemoryMappedFile shadowMemoryMappedFile = Shadow.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class, Throwable.class) .newInstance("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
@Implementation public static MemoryMappedFile mmapRO(String path) throws Throwable { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class) .newInstance("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(0L, 0L); ShadowMemoryMappedFile shadowMemoryMappedFile = Shadow.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class, Throwable.class) .newInstance("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
@Implementation public static MemoryMappedFile mmapRO(String path) throws ErrnoException { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw new ErrnoException("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(-1, -1); ShadowMemoryMappedFile shadowMemoryMappedFile = (ShadowMemoryMappedFile) ShadowExtractor.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw new ErrnoException("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }
/** * Use this to mmap the whole file read-only. */ public static MemoryMappedFile mmapRO(String path) throws ErrnoException { FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); long size = Libcore.os.fstat(fd).st_size; long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0); Libcore.os.close(fd); return new MemoryMappedFile(address, size); }