jnr.posix.POSIX.chmod()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(273)

本文整理了Java中jnr.posix.POSIX.chmod()方法的一些代码示例,展示了POSIX.chmod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.chmod()方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:chmod

POSIX.chmod介绍

暂无

代码示例

代码示例来源: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: stephenh/mirror

public static void setReadOnly(Path absolutePath) {
 posix.chmod(absolutePath.toFile().toString(), Integer.parseInt("0444", 8));
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Run chmod via jnr-posix
 */
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
  PosixAPI.jnr().chmod(f.getAbsolutePath(),mask);
}

代码示例来源:origin: com.github.jnr/jnr-posix

public int chmod(String filename, int mode) {
  return posix().chmod(filename, mode);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int chmod(String filename, int mode) {
  try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int chmod(String filename, int mode) {
  return posix().chmod(filename, mode);
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

public int chmod(String filename, int mode) {
  return posix().chmod(filename, mode);
}

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

public int chmod(String filename, int mode) {
  try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.github.jnr/jnr-posix

public int chmod(String filename, int mode) {
  try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: stephenh/mirror

public static void setWritable(Path absolutePath) {
 FileStat s = posix.stat(absolutePath.toFile().toString());
 posix.chmod(absolutePath.toFile().toString(), s.mode() | Integer.parseInt("0700", 8));
}

代码示例来源:origin: org.python/jython

public static void chmod(PyObject path, int mode) {
  if (os == OS.NT) {
    try {
      if (!absolutePath(path).toFile().setWritable((mode & FileStat.S_IWUSR) != 0)) {
        throw Py.OSError(Errno.EPERM, path);
      }
    } catch (SecurityException ex) {
      throw Py.OSError(Errno.EACCES, path);
    }
  } else if (posix.chmod(absolutePath(path).toString(), mode) < 0) {
    throw errorFromErrno(path);
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod(required = 1)
public IRubyObject chmod(ThreadContext context, IRubyObject arg) {
  checkClosed(context);
  int mode = (int) arg.convertToInteger().getLongValue();
  if (!new File(path).exists()) {
    throw context.runtime.newErrnoENOENTError(path);
  }
  return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@JRubyMethod(required = 1)
public IRubyObject chmod(ThreadContext context, IRubyObject arg) {
  checkClosed(context);
  int mode = (int) arg.convertToInteger().getLongValue();
  if (!new File(path).exists()) {
    throw context.runtime.newErrnoENOENTError(path);
  }
  return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode));
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod(required = 1)
public IRubyObject chmod(ThreadContext context, IRubyObject arg) {
  checkClosed(context);
  int mode = (int) arg.convertToInteger().getLongValue();
  final String path = getPath();
  if ( ! new File(path).exists() ) {
    throw context.runtime.newErrnoENOENTError(path);
  }
  return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode));
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod(required = 1)
public IRubyObject chmod(ThreadContext context, IRubyObject arg) {
  checkClosed(context);
  int mode = (int) arg.convertToInteger().getLongValue();
  final String path = getPath();
  if ( ! new File(path).exists() ) {
    throw context.runtime.newErrnoENOENTError(path);
  }
  return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode));
}

代码示例来源:origin: org.jenkins-ci.plugins/ssh-agent

public String start() throws Exception {
  authSocket = createLocalSocketAddress();
  address = new UnixSocketAddress(new File(authSocket));
  channel = UnixServerSocketChannel.open();
  channel.configureBlocking(false);
  socket = channel.socket();
  socket.bind(address);
  selector = NativeSelectorProvider.getInstance().openSelector();
  channel.register(selector, SelectionKey.OP_ACCEPT, new SshAgentServerSocketHandler());
  POSIXFactory.getPOSIX().chmod(authSocket, 0600);
  thread = new Thread(new AgentSocketAcceptor(), "SSH Agent socket acceptor " +  authSocket);
  thread.setDaemon(true);
  thread.start();
  return authSocket;
}

代码示例来源:origin: org.jruby/jruby-complete

private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException {
  File file = new File(filename);
  FileStat stat = runtime.getPosix().stat(filename);
  if (extension.length() > 0) {
    file.renameTo(new File(filename + extension));
  } else {
    file.delete();
  }
  createNewFile(file);
  runtime.getPosix().chmod(filename, stat.mode());
  runtime.getPosix().chown(filename, stat.uid(), stat.gid());
  runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(),
      new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK));
}

代码示例来源:origin: org.jruby/jruby-core

private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException {
  File file = new File(filename);
  FileStat stat = runtime.getPosix().stat(filename);
  if (extension.length() > 0) {
    file.renameTo(new File(filename + extension));
  } else {
    file.delete();
  }
  createNewFile(file);
  runtime.getPosix().chmod(filename, stat.mode());
  runtime.getPosix().chown(filename, stat.uid(), stat.gid());
  runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(),
      new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private void initializeOpen(IOOptions ioOptions) {
  getRuntime().getPosix().chmod(path, 0600);
  MakeOpenFile();
  
  openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags());
  openFile.setPath(path);
    
  sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private void initializeOpen(IOOptions ioOptions) {
  getRuntime().getPosix().chmod(path, 0600);
  MakeOpenFile();
  
  openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags());
  openFile.setPath(path);
    
  sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600);
}

相关文章

POSIX类方法