public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); }
/** * Do not use. This is for System.loadLibrary use only. * * Checks whether {@code path} can be opened read-only. Similar to File.exists, but doesn't * require read permission on the parent, so it'll work in more cases, and allow you to * remove read permission from more directories. Everyone else should just open(2) and then * use the fd, but the loadLibrary API is broken by its need to ask ClassLoaders where to * find a .so rather than just calling dlopen(3). */ public static boolean canOpenReadOnly(String path) { try { // Use open(2) rather than stat(2) so we require fewer permissions. http://b/6485312. FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0); Libcore.os.close(fd); return true; } catch (ErrnoException errnoException) { return false; } }
try { fd = Libcore.os.open(path, O_RDWR | O_CREAT | O_EXCL, 0600); return true; } catch (ErrnoException errnoException) {
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
/** * 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); }
fd = Libcore.os.open(path, flags, mode); if (fd.valid()) {
public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); }
public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
/** * 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); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
/** * 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); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }
@Override public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); if ((mode & O_ACCMODE) != O_RDONLY) { BlockGuard.getThreadPolicy().onWriteToDisk(); } return os.open(path, flags, mode); }