ForwardingOs.java revision c63f0d4e80a9fd3bdf99cd438d108b750226736a
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.SocketAddress; 22import java.nio.ByteBuffer; 23import libcore.util.MutableInt; 24import libcore.util.MutableLong; 25 26/** 27 * Subclass this if you want to override some {@link Os} methods but otherwise delegate. 28 */ 29public class ForwardingOs implements Os { 30 protected final Os os; 31 32 public ForwardingOs(Os os) { 33 this.os = os; 34 } 35 36 public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); } 37 public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); } 38 public void close(FileDescriptor fd) throws ErrnoException { os.close(fd); } 39 public String[] environ() { return os.environ(); } 40 public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return os.fcntlVoid(fd, cmd); } 41 public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return os.fcntlLong(fd, cmd, arg); } 42 public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return os.fcntlFlock(fd, cmd, arg); } 43 public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } 44 public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } 45 public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException { return os.fstatfs(fd); } 46 public void fsync(FileDescriptor fd) throws ErrnoException { os.fsync(fd); } 47 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException { os.ftruncate(fd, length); } 48 public String getenv(String name) { return os.getenv(name); } 49 public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return os.getsockname(fd); } 50 public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptByte(fd, level, option); } 51 public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptInAddr(fd, level, option); } 52 public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptInt(fd, level, option); } 53 public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptLinger(fd, level, option); } 54 public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return os.getsockoptTimeval(fd, level, option); } 55 public int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return os.ioctlInt(fd, cmd, arg); } 56 public boolean isatty(FileDescriptor fd) { return os.isatty(fd); } 57 public void listen(FileDescriptor fd, int backlog) throws ErrnoException { os.listen(fd, backlog); } 58 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); } 59 public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); } 60 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); } 61 public void mkdir(String path, int mode) throws ErrnoException { os.mkdir(path, mode); } 62 public void mlock(long address, long byteCount) throws ErrnoException { os.mlock(address, byteCount); } 63 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); } 64 public void msync(long address, long byteCount, int flags) throws ErrnoException { os.msync(address, byteCount, flags); } 65 public void munlock(long address, long byteCount) throws ErrnoException { os.munlock(address, byteCount); } 66 public void munmap(long address, long byteCount) throws ErrnoException { os.munmap(address, byteCount); } 67 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } 68 public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); } 69 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } 70 public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); } 71 public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.readv(fd, buffers, offsets, byteCounts); } 72 public void remove(String path) throws ErrnoException { os.remove(path); } 73 public void rename(String oldPath, String newPath) throws ErrnoException { os.rename(oldPath, newPath); } 74 public long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return os.sendfile(outFd, inFd, inOffset, byteCount); } 75 public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { os.setsockoptByte(fd, level, option, value); } 76 public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { os.setsockoptInt(fd, level, option, value); } 77 public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { os.setsockoptLinger(fd, level, option, value); } 78 public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { os.setsockoptTimeval(fd, level, option, value); } 79 public void shutdown(FileDescriptor fd, int how) throws ErrnoException { os.shutdown(fd, how); } 80 public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return os.socket(domain, type, protocol); } 81 public StructStat stat(String path) throws ErrnoException { return os.stat(path); } 82 public StructStatFs statfs(String path) throws ErrnoException { return os.statfs(path); } 83 public String strerror(int errno) { return os.strerror(errno); } 84 public void symlink(String oldPath, String newPath) throws ErrnoException { os.symlink(oldPath, newPath); } 85 public long sysconf(int name) { return os.sysconf(name); } 86 public StructUtsname uname() throws ErrnoException { return os.uname(); } 87 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.write(fd, buffer); } 88 public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.write(fd, bytes, byteOffset, byteCount); } 89 public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.writev(fd, buffers, offsets, byteCounts); } 90} 91