ForwardingOs.java revision a20cc6fca30d18e05db67ceeb0403b7b58ffd364
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; 20 21/** 22 * Subclass this if you want to override some {@link Os} methods but otherwise delegate. 23 */ 24public class ForwardingOs implements Os { 25 protected final Os os; 26 27 public ForwardingOs(Os os) { 28 this.os = os; 29 } 30 31 public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); } 32 public String[] environ() { return os.environ(); } 33 public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } 34 public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } 35 public void fsync(FileDescriptor fd) throws ErrnoException { os.fsync(fd); } 36 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException { os.ftruncate(fd, length); } 37 public String getenv(String name) { return os.getenv(name); } 38 public boolean isatty(FileDescriptor fd) { return os.isatty(fd); } 39 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); } 40 public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); } 41 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); } 42 public void mlock(long address, long byteCount) throws ErrnoException { os.mlock(address, byteCount); } 43 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); } 44 public void msync(long address, long byteCount, int flags) throws ErrnoException { os.msync(address, byteCount, flags); } 45 public void munlock(long address, long byteCount) throws ErrnoException { os.munlock(address, byteCount); } 46 public void munmap(long address, long byteCount) throws ErrnoException { os.munmap(address, byteCount); } 47 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } 48 public void rename(String oldPath, String newPath) throws ErrnoException { os.rename(oldPath, newPath); } 49 public StructStat stat(String path) throws ErrnoException { return os.stat(path); } 50 public String strerror(int errno) { return os.strerror(errno); } 51 public void symlink(String oldPath, String newPath) throws ErrnoException { os.symlink(oldPath, newPath); } 52 public long sysconf(int name) { return os.sysconf(name); } 53} 54