public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } public StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return os.fstatvfs(fd); }
/** * Returns the length of this file in bytes. * * @return the file's length in bytes. * @throws IOException * if this file is closed or some other I/O error occurs. */ public long length() throws IOException { try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
/** * 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); }
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
@Override public void close(FileDescriptor fd) throws ErrnoException { try { if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) { if (isLingerSocket(fd)) { // If the fd is a socket with SO_LINGER set, we might block indefinitely. // We allow non-linger sockets so that apps can close their network // connections in methods like onDestroy which will run on the UI thread. BlockGuard.getThreadPolicy().onNetwork(); } untagSocket(fd); } } catch (ErrnoException ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily // a socket at all. } os.close(fd); }
if (S_ISDIR(Libcore.os.fstat(fd).st_mode)) { throw new ErrnoException("open", EISDIR);
if (S_ISREG(Libcore.os.fstat(fd).st_mode) || ftruncateException.errno != EINVAL) { throw ftruncateException.rethrowAsIOException();
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public long size() throws IOException { checkOpen(); try { return Libcore.os.fstat(fd).st_size; } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
/** * 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); }