Codota Logo
jnr.posix
Code IndexAdd Codota to your IDE (free)

How to use jnr.posix

Best Java code snippets using jnr.posix (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public long getSparseFileSize(int fd) {
  FileStat stat = posix.fstat(fd);
  return stat.blocks() * 512;
}
origin: jenkinsci/jenkins

/**
 * Load the JNR implementation of the POSIX APIs for the current platform.
 * Runtime exceptions will be of type {@link PosixException}.
 * {@link IllegalStateException} will be thrown for methods not implemented on this platform.
 * @return some implementation (even on Windows or unsupported Unix)
 * @since 1.518
 */
public static synchronized POSIX jnr() {
  if (posix == null) {
    posix = POSIXFactory.getPOSIX(new DefaultPOSIXHandler() {
      @Override public void error(Errno error, String extraData) {
        throw new PosixException("native error " + error.description() + " " + extraData, convert(error));
      }
      @Override public void error(Errno error, String methodName, String extraData) {
        throw new PosixException("native error calling " + methodName + ": " + error.description() + " " + extraData, convert(error));
      }
      private org.jruby.ext.posix.POSIX.ERRORS convert(Errno error) {
        try {
          return org.jruby.ext.posix.POSIX.ERRORS.valueOf(error.name());
        } catch (IllegalArgumentException x) {
          return org.jruby.ext.posix.POSIX.ERRORS.EIO; // PosixException.message has real error anyway
        }
      }
    }, true);
  }
  return posix;
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public int getFileSystemBlockSize(int fd) {
  FileStat stat = posix.fstat(fd);
  return Math.toIntExact(stat.blockSize());
}
origin: com.github.jnr/jnr-posix

@Override
public int link(String oldpath, String newpath) {
  boolean linkCreated =  wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null);
  if (!linkCreated) {
    int error = errno();
    handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath);
    return error;
  } else {
    return 0;
  }
}

origin: io.prestosql.cassandra/cassandra-driver

public int setrlimit(int resource, long rlimCur, long rlimMax) {
  RLimit rlim = new DefaultNativeRLimit(getRuntime());
  rlim.init(rlimCur, rlimMax);
  return libc().setrlimit(resource, rlim);
}
origin: traccar/traccar

public void init() throws URISyntaxException {
  String path = new File(
      WindowsService.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent();
  POSIXFactory.getPOSIX().chdir(path);
  System.setProperty("user.dir", path);
  serviceMain = new ServiceMain();
  SERVICE_TABLE_ENTRY entry = new SERVICE_TABLE_ENTRY();
  entry.lpServiceName = serviceName;
  entry.lpServiceProc = serviceMain;
  Advapi32.INSTANCE.StartServiceCtrlDispatcher((SERVICE_TABLE_ENTRY[]) entry.toArray(2));
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public int getFileSystemBlockSize(Path path) {
  FileStat stat = posix.stat(path.toString());
  return Math.toIntExact(stat.blockSize());
}
origin: com.github.jnr/jnr-posix

@Override
public int unsetenv(String envName) {
  if (!wlibc().SetEnvironmentVariableW(new WString(envName), null)) {
    handler.error(EINVAL, "unsetenv", envName);
    return -1;
  }
  
  return 0;
}
origin: jenkinsci/jenkins

/**
 * Gets the mode of a file/directory, if appropriate. Only includes read, write, and
 * execute permissions for the owner, group, and others, i.e. the max return value
 * is 0777. Consider using {@link Files#getPosixFilePermissions} instead if you only
 * care about access permissions.
 * <p>If the file is symlink, the mode is that of the link target, not the link itself.
 * @return a file mode, or -1 if not on Unix
 * @throws PosixException if the file could not be statted, e.g. broken symlink
 */
public static int mode(File f) throws PosixException {
  if(Functions.isWindows())   return -1;
  try {
    if (Util.NATIVE_CHMOD_MODE) {
      return PosixAPI.jnr().stat(f.getPath()).mode();
    } else {
      return Util.permissionsToMode(Files.getPosixFilePermissions(fileToPath(f)));
    }
  } catch (IOException cause) {
    PosixException e = new PosixException("Unable to get file permissions", null);
    e.initCause(cause);
    throw e;
  }
}
origin: apache/incubator-pinot

private void sendSignalToProcess(Process process, Signal signal) {
 int processPid = getProcessPid(process);
 if (processPid != -1) {
  LOGGER.info("Sending signal {} to process {}", signal.intValue(), processPid);
  POSIXFactory.getNativePOSIX().kill(processPid, signal.intValue());
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

 /**
  * Returns the JVM's process identifier (PID) via a system call to {@code getpid}.
  *
  * @return the JVM's process identifier (PID).
  * @throws UnsupportedOperationException if JNR POSIX library is not loaded or {@code getpid} is
  *     not available.
  */
 public static int processId() {
  if (!isGetpidAvailable())
   throw new UnsupportedOperationException(
     "JNR POSIX library not loaded or getpid not available");
  return PosixLoader.POSIX.getpid();
 }
}
origin: jenkinsci/jenkins

/**
 * Change permissions via NIO.
 */
private static void _chmod(File f, int mask) throws IOException {
  // TODO WindowsPosix actually does something here (WindowsLibC._wchmod); should we let it?
  // Anyway the existing calls already skip this method if on Windows.
  if (File.pathSeparatorChar==';')  return; // noop
  if (Util.NATIVE_CHMOD_MODE) {
    PosixAPI.jnr().chmod(f.getAbsolutePath(), mask);
  } else {
    Files.setPosixFilePermissions(fileToPath(f), Util.modeToPermissions(mask));
  }
}
origin: com.github.jnr/jnr-posix

public FileStat stat(String path) {
  FileStat stat = allocateStat(); 
  if (helper.stat(path, stat) < 0) handler.error(ENOENT, "stat", path);
  
  return stat;
}
origin: com.github.jnr/jnr-posix

  public int ioprio_set(int which, int who, int ioprio) {
    Syscall.ABI abi = Syscall.abi();
    if (abi == null) {
      handler.unimplementedError("ioprio_set");
      return -1;
    }

    return libc().syscall(abi.__NR_ioprio_set(), which, who, ioprio);
  }
}
origin: com.github.jnr/jnr-posix

public int ioprio_get(int which, int who) {
  Syscall.ABI abi = Syscall.abi();
  if (abi == null) {
    handler.unimplementedError("ioprio_get");
    return -1;
  }
  return libc().syscall(abi.__NR_ioprio_get(), which, who);
}
origin: io.prestosql.cassandra/cassandra-driver

@Override
public int link(String oldpath, String newpath) {
  boolean linkCreated =  wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null);
  if (!linkCreated) {
    int error = errno();
    handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath);
    return error;
  } else {
    return 0;
  }
}

origin: com.facebook.presto.cassandra/cassandra-driver

public int setrlimit(int resource, long rlimCur, long rlimMax) {
  RLimit rlim = new DefaultNativeRLimit(getRuntime());
  rlim.init(rlimCur, rlimMax);
  return libc().setrlimit(resource, rlim);
}
origin: io.prestosql.cassandra/cassandra-driver

@Override
public int unsetenv(String envName) {
  if (!wlibc().SetEnvironmentVariableW(new WString(envName), null)) {
    handler.error(EINVAL, "unsetenv", envName);
    return -1;
  }
  
  return 0;
}
origin: com.facebook.presto.cassandra/cassandra-driver

@Override
public int link(String oldpath, String newpath) {
  boolean linkCreated =  wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null);
  if (!linkCreated) {
    int error = errno();
    handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath);
    return error;
  } else {
    return 0;
  }
}

origin: com.github.jnr/jnr-posix

public int setrlimit(int resource, long rlimCur, long rlimMax) {
  RLimit rlim = new DefaultNativeRLimit(getRuntime());
  rlim.init(rlimCur, rlimMax);
  return libc().setrlimit(resource, rlim);
}
jnr.posix

Most used classes

  • POSIX
  • POSIXFactory
  • FileStat
  • JavaSecuredFile
    This file catches any SecurityExceptions raised when access to a file is denied and responds as if t
  • LibC
  • FieldAccess,
  • JavaLibCHelper,
  • RLimit,
  • Timeval,
  • CmsgHdr,
  • SpawnAttribute,
  • Times,
  • AixFileStat,
  • AixPOSIX,
  • AixPasswd,
  • BaseFileStat,
  • BaseNativePOSIX,
  • CheckedPOSIX,
  • DefaultNativeGroup
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now