ForwardingOs.java revision bbac92e691de7d570928ddfba639067978e55b06
152724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes/* 252724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * Copyright (C) 2011 The Android Open Source Project 352724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * 452724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 552724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * you may not use this file except in compliance with the License. 652724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * You may obtain a copy of the License at 752724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * 852724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 952724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * 1052724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * Unless required by applicable law or agreed to in writing, software 1152724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 1252724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1352724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * See the License for the specific language governing permissions and 1452724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * limitations under the License. 1552724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes */ 1652724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes 1752724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughespackage libcore.io; 1852724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes 1952724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughesimport java.io.FileDescriptor; 2026c7025a7a919044771fb89031161bd26fe03032Elliott Hughesimport java.nio.ByteBuffer; 2152724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes 2252724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes/** 2352724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes * Subclass this if you want to override some {@link Os} methods but otherwise delegate. 2452724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes */ 2552724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughespublic class ForwardingOs implements Os { 2652724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes protected final Os os; 2752724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes 2852724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public ForwardingOs(Os os) { 2952724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes this.os = os; 3052724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes } 3152724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes 3252724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); } 33b7190190e0ef8de883c952efb319ce7748831faaElliott Hughes public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); } 3452724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public String[] environ() { return os.environ(); } 35fc549a0b0388987b26dea524894d75a63d14783bElliott Hughes public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return os.fcntlVoid(fd, cmd); } 36fc549a0b0388987b26dea524894d75a63d14783bElliott Hughes public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return os.fcntlLong(fd, cmd, arg); } 37fc549a0b0388987b26dea524894d75a63d14783bElliott Hughes public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return os.fcntlFlock(fd, cmd, arg); } 3852724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public void fdatasync(FileDescriptor fd) throws ErrnoException { os.fdatasync(fd); } 3947cb338d43f75dd998b29caaaa9446c5705217d1Elliott Hughes public StructStat fstat(FileDescriptor fd) throws ErrnoException { return os.fstat(fd); } 4059fa7163774d6930a174bc038414a4b780581957Elliott Hughes public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException { return os.fstatfs(fd); } 4152724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public void fsync(FileDescriptor fd) throws ErrnoException { os.fsync(fd); } 42f5333fd2094bdac4d6506177b1964b79afa64d77Elliott Hughes public void ftruncate(FileDescriptor fd, long length) throws ErrnoException { os.ftruncate(fd, length); } 4352724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public String getenv(String name) { return os.getenv(name); } 44461d0d860814c68154d8dd06d24f94118f33d28aElliott Hughes public int ioctlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException { return os.ioctlInt(fd, cmd, arg); } 459a3f363523000704205df288f8b6f2f48c0d8563Elliott Hughes public boolean isatty(FileDescriptor fd) { return os.isatty(fd); } 46e1502d64e937001636fca3d62b2552ef2a34d05fElliott Hughes public void listen(FileDescriptor fd, int backlog) throws ErrnoException { os.listen(fd, backlog); } 47dedaccdfa07c370a58cba08b096133ad9eec0ec3Elliott Hughes public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); } 4847cb338d43f75dd998b29caaaa9446c5705217d1Elliott Hughes public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); } 490f746ff511162add42eeabaf14ba70ace874c6f4Elliott Hughes public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); } 50c7fa20701d5e9398c38f4615ed293acfce1c0cf6Elliott Hughes public void mkdir(String path, int mode) throws ErrnoException { os.mkdir(path, mode); } 517e13c0f05ac9e7c55682d10e953dd4cbd5e6107cElliott Hughes public void mlock(long address, long byteCount) throws ErrnoException { os.mlock(address, byteCount); } 527e25eff38a191d9c19e45093f4fde5102fb09d78Elliott Hughes 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); } 537e25eff38a191d9c19e45093f4fde5102fb09d78Elliott Hughes public void msync(long address, long byteCount, int flags) throws ErrnoException { os.msync(address, byteCount, flags); } 547e13c0f05ac9e7c55682d10e953dd4cbd5e6107cElliott Hughes public void munlock(long address, long byteCount) throws ErrnoException { os.munlock(address, byteCount); } 557e25eff38a191d9c19e45093f4fde5102fb09d78Elliott Hughes public void munmap(long address, long byteCount) throws ErrnoException { os.munmap(address, byteCount); } 560ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes public FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return os.open(path, flags, mode); } 5741f0605d2c809bd9bc1c0fb68d86b49a0f59b6c5Elliott Hughes public FileDescriptor[] pipe() throws ErrnoException { return os.pipe(); } 5826c7025a7a919044771fb89031161bd26fe03032Elliott Hughes public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.read(fd, buffer); } 5926c7025a7a919044771fb89031161bd26fe03032Elliott Hughes public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.read(fd, bytes, byteOffset, byteCount); } 60bbac92e691de7d570928ddfba639067978e55b06Elliott Hughes public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.readv(fd, buffers, offsets, byteCounts); } 61c7fa20701d5e9398c38f4615ed293acfce1c0cf6Elliott Hughes public void remove(String path) throws ErrnoException { os.remove(path); } 62a20cc6fca30d18e05db67ceeb0403b7b58ffd364Elliott Hughes public void rename(String oldPath, String newPath) throws ErrnoException { os.rename(oldPath, newPath); } 6359e4744d27231f260271dbbca406e0cc39768116Elliott Hughes public void shutdown(FileDescriptor fd, int how) throws ErrnoException { os.shutdown(fd, how); } 6447cb338d43f75dd998b29caaaa9446c5705217d1Elliott Hughes public StructStat stat(String path) throws ErrnoException { return os.stat(path); } 6559fa7163774d6930a174bc038414a4b780581957Elliott Hughes public StructStatFs statfs(String path) throws ErrnoException { return os.statfs(path); } 6652724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes public String strerror(int errno) { return os.strerror(errno); } 67a20cc6fca30d18e05db67ceeb0403b7b58ffd364Elliott Hughes public void symlink(String oldPath, String newPath) throws ErrnoException { os.symlink(oldPath, newPath); } 686fc1a0e1e68dc2e0d12341548e58fa7f1c5dafc4Elliott Hughes public long sysconf(int name) { return os.sysconf(name); } 697341b9ed7157a1e37a3e69a0974676da358b735aElliott Hughes public StructUtsname uname() throws ErrnoException { return os.uname(); } 7078c7cc547101002b9f9043cf3845970719d1bda8Elliott Hughes public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException { return os.write(fd, buffer); } 7178c7cc547101002b9f9043cf3845970719d1bda8Elliott Hughes public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException { return os.write(fd, bytes, byteOffset, byteCount); } 72bbac92e691de7d570928ddfba639067978e55b06Elliott Hughes public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException { return os.writev(fd, buffers, offsets, byteCounts); } 7352724d3ebd4ccaaa4b9f5576e329d4272cde8ea9Elliott Hughes} 74