ForwardingOs.java revision 9e67ca71d3d4a489a157abadc5ba519ced7a0b50
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package libcore.io; 18 19import java.io.FileDescriptor; 20import java.net.InetAddress; 21import java.net.InetSocketAddress; 22import java.net.SocketAddress; 23import java.nio.ByteBuffer; 24import libcore.util.MutableInt; 25import libcore.util.MutableLong; 26 27/** 28 * Subclass this if you want to override some {@link Os} methods but otherwise delegate. 29 */ 30public class ForwardingOs implements Os { 31 protected final Os os; 32 33 public ForwardingOs(Os os) { 34 this.os = os; 35 } 36 37 public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException { return os.accept(fd, peerAddress); } 38 public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); } 39 public void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException { os.bind(fd, address, port); } 40 public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); } 41 public void close(FileDescriptor fd) throws ErrnoException { os.close(fd); } 42 public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException { os.connect(fd, address, port); } 43 public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return os.dup(oldFd); } 44 public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return os.dup2(oldFd, newFd); } 45 public String[] environ() { return os.environ(); } 46 public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return os.fcntlVoid(fd, cmd); } 47 public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return os.fcntlLong(fd, cmd, arg); } 48 public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return os.fcntlFlock(fd, cmd, arg); } 49 public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } 50 public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } 51 public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException { return os.fstatfs(fd); } 52 public void fsync(FileDescriptor fd) throws ErrnoException { os.fsync(fd); } 53 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException { os.ftruncate(fd, length); } 54 public String gai_strerror(int error) { return os.gai_strerror(error); } 55 public InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException { return os.getaddrinfo(node, hints); } 56 public int getegid() { return os.getegid(); } 57 public int geteuid() { return os.geteuid(); } 58 public int getgid() { return os.getgid(); } 59 public String getenv(String name) { return os.getenv(name); } 60 public String getnameinfo(InetAddress address, int flags) throws GaiException { return os.getnameinfo(address, flags); } 61 public int getpid() { return os.getpid(); } 62 public int getppid() { return os.getppid(); } 63 public StructPasswd getpwnam(String name) throws ErrnoException { return os.getpwnam(name); } 64 public StructPasswd getpwuid(int uid) throws ErrnoException { return os.getpwuid(uid); } 65 public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return os.getsockname(fd); } 66 public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptByte(fd, level, option); } 67 public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptInAddr(fd, level, option); } 68 public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptInt(fd, level, option); } 69 public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptLinger(fd, level, option); } 70 public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptTimeval(fd, level, option); } 71 public int getuid() { return os.getuid(); } 72 public String if_indextoname(int index) { return os.if_indextoname(index); } 73 public InetAddress inet_aton(String address) { return os.inet_aton(address); } 74 public InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return os.ioctlInetAddress(fd, cmd, interfaceName); } 75 public int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return os.ioctlInt(fd, cmd, arg); } 76 public boolean isatty(FileDescriptor fd) { return os.isatty(fd); } 77 public void kill(int pid, int signal) throws ErrnoException { os.kill(pid, signal); } 78 public void listen(FileDescriptor fd, int backlog) throws ErrnoException { os.listen(fd, backlog); } 79 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); } 80 public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); } 81 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); } 82 public void mkdir(String path, int mode) throws ErrnoException { os.mkdir(path, mode); } 83 public void mlock(long address, long byteCount) throws ErrnoException { os.mlock(address, byteCount); } 84 public long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException { return os.mmap(address, byteCount, prot, flags, fd, offset); } 85 public void msync(long address, long byteCount, int flags) throws ErrnoException { os.msync(address, byteCount, flags); } 86 public void munlock(long address, long byteCount) throws ErrnoException { os.munlock(address, byteCount); } 87 public void munmap(long address, long byteCount) throws ErrnoException { os.munmap(address, byteCount); } 88 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } 89 public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); } 90 public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return os.poll(fds, timeoutMs); } 91 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } 92 public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); } 93 public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.readv(fd, buffers, offsets, byteCounts); } 94 public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException { return os.recvfrom(fd, buffer, flags, srcAddress); } 95 public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException { return os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress); } 96 public void remove(String path) throws ErrnoException { os.remove(path); } 97 public void rename(String oldPath, String newPath) throws ErrnoException { os.rename(oldPath, newPath); } 98 public long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return os.sendfile(outFd, inFd, inOffset, byteCount); } 99 public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException { return os.sendto(fd, buffer, flags, inetAddress, port); } 100 public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException { return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); } 101 public void setegid(int egid) throws ErrnoException { os.setegid(egid); } 102 public void seteuid(int euid) throws ErrnoException { os.seteuid(euid); } 103 public void setgid(int gid) throws ErrnoException { os.setgid(gid); } 104 public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { os.setsockoptByte(fd, level, option, value); } 105 public void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { os.setsockoptIfreq(fd, level, option, value); } 106 public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { os.setsockoptInt(fd, level, option, value); } 107 public void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { os.setsockoptIpMreqn(fd, level, option, value); } 108 public void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { os.setsockoptGroupReq(fd, level, option, value); } 109 public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { os.setsockoptLinger(fd, level, option, value); } 110 public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { os.setsockoptTimeval(fd, level, option, value); } 111 public void setuid(int uid) throws ErrnoException { os.setuid(uid); } 112 public void shutdown(FileDescriptor fd, int how) throws ErrnoException { os.shutdown(fd, how); } 113 public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return os.socket(domain, type, protocol); } 114 public StructStat stat(String path) throws ErrnoException { return os.stat(path); } 115 public StructStatFs statfs(String path) throws ErrnoException { return os.statfs(path); } 116 public String strerror(int errno) { return os.strerror(errno); } 117 public void symlink(String oldPath, String newPath) throws ErrnoException { os.symlink(oldPath, newPath); } 118 public long sysconf(int name) { return os.sysconf(name); } 119 public StructUtsname uname() throws ErrnoException { return os.uname(); } 120 public int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return os.waitpid(pid, status, options); } 121 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.write(fd, buffer); } 122 public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.write(fd, bytes, byteOffset, byteCount); } 123 public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.writev(fd, buffers, offsets, byteCounts); } 124} 125