Tabnine Logo
Os
Code IndexAdd Tabnine to your IDE (free)

How to use
Os
in
libcore.io

Best Java code snippets using libcore.io.Os (Showing top 20 results out of 315)

origin: robovm/robovm

int flags = Libcore.os.fcntlVoid(fd, F_GETFL);
if (timeout > 0 && (flags & O_NONBLOCK) == 0) {
  StructPollfd pfd = new StructPollfd();
  while (true) {
    try {
      if (timeout <= 0 || Libcore.os.poll(pfds, timeout) == 0) {
        throw new SocketTimeoutException("accept() timed out");
FileDescriptor clientFd = Libcore.os.accept(fd, peerAddress);
origin: robovm/robovm

private boolean doAccess(int mode) {
  try {
    return Libcore.os.access(path, mode);
  } catch (ErrnoException errnoException) {
    return false;
  }
}
origin: robovm/robovm

public void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { os.bind(fd, address, port); }
public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); }
origin: robovm/robovm

private boolean doChmod(int mask, boolean set) {
  try {
    StructStat sb = Libcore.os.stat(path);
    int newMode = set ? (sb.st_mode | mask) : (sb.st_mode & ~mask);
    Libcore.os.chmod(path, newMode);
    return true;
  } catch (ErrnoException errnoException) {
    return false;
  }
}
origin: robovm/robovm

/**
 * Do not use. This is for System.loadLibrary use only.
 *
 * Checks whether {@code path} can be opened read-only. Similar to File.exists, but doesn't
 * require read permission on the parent, so it'll work in more cases, and allow you to
 * remove read permission from more directories. Everyone else should just open(2) and then
 * use the fd, but the loadLibrary API is broken by its need to ask ClassLoaders where to
 * find a .so rather than just calling dlopen(3).
 */
public static boolean canOpenReadOnly(String path) {
  try {
    // Use open(2) rather than stat(2) so we require fewer permissions. http://b/6485312.
    FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0);
    Libcore.os.close(fd);
    return true;
  } catch (ErrnoException errnoException) {
    return false;
  }
}
origin: robovm/robovm

/**
 * Use this to mmap the whole file read-only.
 */
public static MemoryMappedFile mmapRO(String path) throws ErrnoException {
  FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0);
  long size = Libcore.os.fstat(fd).st_size;
  long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0);
  Libcore.os.close(fd);
  return new MemoryMappedFile(address, size);
}
origin: robovm/robovm

public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return os.accept(fd, peerAddress); }
public boolean access(String path, int mode) throws ErrnoException { return os.access(path, mode); }
origin: robovm/robovm

public String[] environ() { return os.environ(); }
public void execv(String filename, String[] argv) throws ErrnoException { os.execv(filename, argv); }
origin: robovm/robovm

public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { os.connect(fd, address, port); }
public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return os.dup(oldFd); }
origin: robovm/robovm

public void chown(String path, int uid, int gid) throws ErrnoException { os.chown(path, uid, gid); }
public void close(FileDescriptor fd) throws ErrnoException { os.close(fd); }
origin: robovm/robovm

public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return os.dup2(oldFd, newFd); }
public String[] environ() { return os.environ(); }
origin: robovm/robovm

public FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return os.dup(oldFd); }
public FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return os.dup2(oldFd, newFd); }
origin: robovm/robovm

@Override public void close(FileDescriptor fd) throws ErrnoException {
  try {
    if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) {
      if (isLingerSocket(fd)) {
        // If the fd is a socket with SO_LINGER set, we might block indefinitely.
        // We allow non-linger sockets so that apps can close their network
        // connections in methods like onDestroy which will run on the UI thread.
        BlockGuard.getThreadPolicy().onNetwork();
      }
      untagSocket(fd);
    }
  } catch (ErrnoException ignored) {
    // We're called via Socket.close (which doesn't ask for us to be called), so we
    // must not throw here, because Socket.close must not throw if asked to close an
    // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily
    // a socket at all.
  }
  os.close(fd);
}
origin: robovm/robovm

public void close(FileDescriptor fd) throws ErrnoException { os.close(fd); }
public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { os.connect(fd, address, port); }
origin: robovm/robovm

public void chmod(String path, int mode) throws ErrnoException { os.chmod(path, mode); }
public void chown(String path, int uid, int gid) throws ErrnoException { os.chown(path, uid, gid); }
origin: MobiVM/robovm

/**
 * Use this to mmap the whole file read-only.
 */
public static MemoryMappedFile mmapRO(String path) throws ErrnoException {
  FileDescriptor fd = Libcore.os.open(path, O_RDONLY, 0);
  long size = Libcore.os.fstat(fd).st_size;
  long address = Libcore.os.mmap(0L, size, PROT_READ, MAP_SHARED, fd, 0);
  Libcore.os.close(fd);
  return new MemoryMappedFile(address, size);
}
origin: MobiVM/robovm

private boolean doChmod(int mask, boolean set) {
  try {
    StructStat sb = Libcore.os.stat(path);
    int newMode = set ? (sb.st_mode | mask) : (sb.st_mode & ~mask);
    Libcore.os.chmod(path, newMode);
    return true;
  } catch (ErrnoException errnoException) {
    return false;
  }
}
origin: robovm/robovm

@Override public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException {
  BlockGuard.getThreadPolicy().onNetwork();
  return tagSocket(os.accept(fd, peerAddress));
}
origin: robovm/robovm

/**
 * Returns an unmodifiable map of all environment variables to their values.
 */
public static Map<String, String> getenv() {
  Map<String, String> map = new HashMap<String, String>();
  for (String entry : Libcore.os.environ()) {
    int index = entry.indexOf('=');
    if (index != -1) {
      map.put(entry.substring(0, index), entry.substring(index + 1));
    }
  }
  return new SystemEnvironment(map);
}
origin: robovm/robovm

@Override
public void disconnect() {
  try {
    Libcore.os.connect(fd, InetAddress.UNSPECIFIED, 0);
  } catch (ErrnoException errnoException) {
    throw new AssertionError(errnoException);
  } catch (SocketException ignored) {
    // Thrown if the socket has already been closed, but this method can't throw anything.
  }
  connectedPort = -1;
  connectedAddress = null;
  isNativeConnected = false;
}
libcore.ioOs

Most used methods

  • accept
  • access
  • bind
  • chmod
  • chown
  • close
  • connect
  • dup
  • dup2
  • environ
  • execv
  • execve
  • execv,
  • execve,
  • fchmod,
  • fchown,
  • fcntlFlock,
  • fcntlLong,
  • fcntlVoid,
  • fdatasync,
  • fstat,
  • fstatvfs

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • getContentResolver (Context)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now