Os.java revision a5fb706fe4a6dbeaaf4cb1f8bbc2c68b0a2a3f3c
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 26public interface Os { 27 public boolean access(String path, int mode) throws ErrnoException; 28 public void chmod(String path, int mode) throws ErrnoException; 29 public void close(FileDescriptor fd) throws ErrnoException; 30 public String[] environ(); 31 public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException; 32 public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException; 33 public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException; 34 public void fdatasync(FileDescriptor fd) throws ErrnoException; 35 public StructStat fstat(FileDescriptor fd) throws ErrnoException; 36 public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException; 37 public void fsync(FileDescriptor fd) throws ErrnoException; 38 public void ftruncate(FileDescriptor fd, long length) throws ErrnoException; 39 public String gai_strerror(int error); 40 public String getenv(String name); 41 /* TODO: break into getnameinfoHost and getnameinfoService? */ 42 public String getnameinfo(InetAddress address, int flags) throws GaiException; 43 public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException; 44 public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException; 45 public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException; 46 public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException; 47 public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException; 48 public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException; 49 public String if_indextoname(int index); 50 public InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException; 51 public int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException; 52 public boolean isatty(FileDescriptor fd); 53 public void kill(int pid, int signal) throws ErrnoException; 54 public void listen(FileDescriptor fd, int backlog) throws ErrnoException; 55 public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException; 56 public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException; 57 public void mkdir(String path, int mode) throws ErrnoException; 58 public void mlock(long address, long byteCount) throws ErrnoException; 59 public long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException; 60 public void msync(long address, long byteCount, int flags) throws ErrnoException; 61 public void munlock(long address, long byteCount) throws ErrnoException; 62 public void munmap(long address, long byteCount) throws ErrnoException; 63 public FileDescriptor open(String path, int flags, int mode) throws ErrnoException; 64 public FileDescriptor[] pipe() throws ErrnoException; 65 public StructStat lstat(String path) throws ErrnoException; 66 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException; 67 public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException; 68 public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException; 69 public void remove(String path) throws ErrnoException; 70 public void rename(String oldPath, String newPath) throws ErrnoException; 71 public long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException; 72 public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 73 public void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException; 74 public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 75 public void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException; 76 public void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException; 77 public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException; 78 public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException; 79 public void shutdown(FileDescriptor fd, int how) throws ErrnoException; 80 public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException; 81 public StructStat stat(String path) throws ErrnoException; 82 /* TODO: replace statfs with statvfs. */ 83 public StructStatFs statfs(String path) throws ErrnoException; 84 public String strerror(int errno); 85 public void symlink(String oldPath, String newPath) throws ErrnoException; 86 public long sysconf(int name); 87 public StructUtsname uname() throws ErrnoException; 88 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException; 89 public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException; 90 public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException; 91} 92