ForwardingOs.java revision 461d0d860814c68154d8dd06d24f94118f33d28a
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.nio.ByteBuffer; 21 22/** 23 * Subclass this if you want to override some {@link Os} methods but otherwise delegate. 24 */ 25public class ForwardingOs implements Os { 26 protected final Os os; 27 28 public ForwardingOs(Os os) { 29 this.os = os; 30 } 31 32 public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); } 33 public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); } 34 public String[] environ() { return os.environ(); } 35 public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return os.fcntlVoid(fd, cmd); } 36 public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return os.fcntlLong(fd, cmd, arg); } 37 public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return os.fcntlFlock(fd, cmd, arg); } 38 public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } 39 public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } 40 public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException { return os.fstatfs(fd); } 41 public void fsync(FileDescriptor fd) throws ErrnoException { os.fsync(fd); } 42 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException { os.ftruncate(fd, length); } 43 public String getenv(String name) { return os.getenv(name); } 44 public int ioctlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException { return os.ioctlInt(fd, cmd, arg); } 45 public boolean isatty(FileDescriptor fd) { return os.isatty(fd); } 46 public void listen(FileDescriptor fd, int backlog) throws ErrnoException { os.listen(fd, backlog); } 47 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); } 48 public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); } 49 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); } 50 public void mkdir(String path, int mode) throws ErrnoException { os.mkdir(path, mode); } 51 public void mlock(long address, long byteCount) throws ErrnoException { os.mlock(address, byteCount); } 52 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); } 53 public void msync(long address, long byteCount, int flags) throws ErrnoException { os.msync(address, byteCount, flags); } 54 public void munlock(long address, long byteCount) throws ErrnoException { os.munlock(address, byteCount); } 55 public void munmap(long address, long byteCount) throws ErrnoException { os.munmap(address, byteCount); } 56 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } 57 public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); } 58 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } 59 public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); } 60 public void remove(String path) throws ErrnoException { os.remove(path); } 61 public void rename(String oldPath, String newPath) throws ErrnoException { os.rename(oldPath, newPath); } 62 public void shutdown(FileDescriptor fd, int how) throws ErrnoException { os.shutdown(fd, how); } 63 public StructStat stat(String path) throws ErrnoException { return os.stat(path); } 64 public StructStatFs statfs(String path) throws ErrnoException { return os.statfs(path); } 65 public String strerror(int errno) { return os.strerror(errno); } 66 public void symlink(String oldPath, String newPath) throws ErrnoException { os.symlink(oldPath, newPath); } 67 public long sysconf(int name) { return os.sysconf(name); } 68 public StructUtsname uname() throws ErrnoException { return os.uname(); } 69 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.write(fd, buffer); } 70 public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.write(fd, bytes, byteOffset, byteCount); } 71} 72