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