public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); }
public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); } public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.readv(fd, buffers, offsets, byteCounts); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
public FileReader readFully() throws IOException { int read; int capacity = bytes.length; try { while ((read = Libcore.os.read(fd, bytes, count, capacity - count)) != 0) { count += read; if (count == capacity) { if (unknownLength) { // If we don't know the length of this file, we need to continue // reading until we reach EOF. Double the capacity in preparation. final int newCapacity = capacity * 2; byte[] newBytes = new byte[newCapacity]; System.arraycopy(bytes, 0, newBytes, 0, capacity); bytes = newBytes; capacity = newCapacity; } else { // We know the length of this file and we've read the right number // of bytes from it, return. break; } } } return this; } catch (ErrnoException e) { throw e.rethrowAsIOException(); } finally { closeQuietly(fd); } }
/** * java.io thinks that a read at EOF is an error and should return -1, contrary to traditional * Unix practice where you'd read until you got 0 bytes (and any future read would return -1). */ public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException { Arrays.checkOffsetAndCount(bytes.length, byteOffset, byteCount); if (byteCount == 0) { return 0; } try { int readCount = Libcore.os.read(fd, bytes, byteOffset, byteCount); if (readCount == 0) { return -1; } return readCount; } catch (ErrnoException errnoException) { if (errnoException.errno == EAGAIN) { // We return 0 rather than throw if we try to read from an empty non-blocking pipe. return 0; } throw errnoException.rethrowAsIOException(); } }
try { if (position == -1) { bytesRead = Libcore.os.read(fd, buffer); } else { bytesRead = Libcore.os.pread(fd, buffer, position);
public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }
@Override public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, bytes, byteOffset, byteCount); }
@Override public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { BlockGuard.getThreadPolicy().onReadFromDisk(); return os.read(fd, buffer); }