/android/upstream/libcore/io/Os.java

https://bitbucket.org/festevezga/xobotos · Java · 122 lines · 101 code · 3 blank · 18 comment · 0 complexity · 0e2c5fb84eb4e2f631672f1fe64d0222 MD5 · raw file

  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. package libcore.io;
  17. import java.io.FileDescriptor;
  18. import java.net.InetAddress;
  19. import java.net.InetSocketAddress;
  20. import java.net.SocketAddress;
  21. import java.nio.ByteBuffer;
  22. import libcore.util.MutableInt;
  23. import libcore.util.MutableLong;
  24. public interface Os {
  25. public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException;
  26. public boolean access(String path, int mode) throws ErrnoException;
  27. public void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException;
  28. public void chmod(String path, int mode) throws ErrnoException;
  29. public void close(FileDescriptor fd) throws ErrnoException;
  30. public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException;
  31. public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException;
  32. public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException;
  33. public String[] environ();
  34. public int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException;
  35. public int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException;
  36. public int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException;
  37. public void fdatasync(FileDescriptor fd) throws ErrnoException;
  38. public StructStat fstat(FileDescriptor fd) throws ErrnoException;
  39. public StructStatFs fstatfs(FileDescriptor fd) throws ErrnoException;
  40. public void fsync(FileDescriptor fd) throws ErrnoException;
  41. public void ftruncate(FileDescriptor fd, long length) throws ErrnoException;
  42. public String gai_strerror(int error);
  43. public InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException;
  44. public int getegid();
  45. public int geteuid();
  46. public int getgid();
  47. public String getenv(String name);
  48. /* TODO: break into getnameinfoHost and getnameinfoService? */
  49. public String getnameinfo(InetAddress address, int flags) throws GaiException;
  50. public int getpid();
  51. public int getppid();
  52. public StructPasswd getpwnam(String name) throws ErrnoException;
  53. public StructPasswd getpwuid(int uid) throws ErrnoException;
  54. public SocketAddress getsockname(FileDescriptor fd) throws ErrnoException;
  55. public int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException;
  56. public InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException;
  57. public int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException;
  58. public StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException;
  59. public StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException;
  60. public int getuid();
  61. public String if_indextoname(int index);
  62. public InetAddress inet_pton(int family, String address);
  63. public InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException;
  64. public int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException;
  65. public boolean isatty(FileDescriptor fd);
  66. public void kill(int pid, int signal) throws ErrnoException;
  67. public void listen(FileDescriptor fd, int backlog) throws ErrnoException;
  68. public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException;
  69. public StructStat lstat(String path) throws ErrnoException;
  70. public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException;
  71. public void mkdir(String path, int mode) throws ErrnoException;
  72. public void mlock(long address, long byteCount) throws ErrnoException;
  73. public long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException;
  74. public void msync(long address, long byteCount, int flags) throws ErrnoException;
  75. public void munlock(long address, long byteCount) throws ErrnoException;
  76. public void munmap(long address, long byteCount) throws ErrnoException;
  77. public FileDescriptor open(String path, int flags, int mode) throws ErrnoException;
  78. public FileDescriptor[] pipe() throws ErrnoException;
  79. /* TODO: if we used the non-standard ppoll(2) behind the scenes, we could take a long timeout. */
  80. public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException;
  81. public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException;
  82. public int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException;
  83. public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException;
  84. public int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException;
  85. public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException;
  86. public int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException;
  87. public int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException;
  88. public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException;
  89. public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException;
  90. public void remove(String path) throws ErrnoException;
  91. public void rename(String oldPath, String newPath) throws ErrnoException;
  92. public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException;
  93. public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException;
  94. public long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException;
  95. public void setegid(int egid) throws ErrnoException;
  96. public void seteuid(int euid) throws ErrnoException;
  97. public void setgid(int gid) throws ErrnoException;
  98. public void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
  99. public void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException;
  100. public void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
  101. public void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException;
  102. public void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException;
  103. public void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException;
  104. public void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException;
  105. public void setuid(int uid) throws ErrnoException;
  106. public void shutdown(FileDescriptor fd, int how) throws ErrnoException;
  107. public FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException;
  108. public StructStat stat(String path) throws ErrnoException;
  109. /* TODO: replace statfs with statvfs. */
  110. public StructStatFs statfs(String path) throws ErrnoException;
  111. public String strerror(int errno);
  112. public void symlink(String oldPath, String newPath) throws ErrnoException;
  113. public long sysconf(int name);
  114. public StructUtsname uname();
  115. public int waitpid(int pid, MutableInt status, int options) throws ErrnoException;
  116. public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException;
  117. public int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException;
  118. public int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException;
  119. }