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

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

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

POSIX.stat介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

  1. /** {@inheritDoc} */
  2. @Override public int getFileSystemBlockSize(Path path) {
  3. FileStat stat = posix.stat(path.toString());
  4. return Math.toIntExact(stat.blockSize());
  5. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Gets the mode of a file/directory, if appropriate. Only includes read, write, and
  3. * execute permissions for the owner, group, and others, i.e. the max return value
  4. * is 0777. Consider using {@link Files#getPosixFilePermissions} instead if you only
  5. * care about access permissions.
  6. * <p>If the file is symlink, the mode is that of the link target, not the link itself.
  7. * @return a file mode, or -1 if not on Unix
  8. * @throws PosixException if the file could not be statted, e.g. broken symlink
  9. */
  10. public static int mode(File f) throws PosixException {
  11. if(Functions.isWindows()) return -1;
  12. try {
  13. if (Util.NATIVE_CHMOD_MODE) {
  14. return PosixAPI.jnr().stat(f.getPath()).mode();
  15. } else {
  16. return Util.permissionsToMode(Files.getPosixFilePermissions(fileToPath(f)));
  17. }
  18. } catch (IOException cause) {
  19. PosixException e = new PosixException("Unable to get file permissions", null);
  20. e.initCause(cause);
  21. throw e;
  22. }
  23. }

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

  1. public FileStat stat(String path) {
  2. return posix().stat(path);
  3. }

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

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

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

  1. @Override
  2. public FileStat stat() {
  3. FileStat stat = posix.allocateStat();
  4. return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
  5. }

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

  1. @Override
  2. public FileStat stat() {
  3. FileStat stat = posix.allocateStat();
  4. return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
  5. }

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

  1. /**
  2. * Gets the mode of a file/directory, if appropriate.
  3. * @return a file mode, or -1 if not on Unix
  4. * @throws PosixException if the file could not be statted, e.g. broken symlink
  5. */
  6. public static int mode(File f) throws PosixException {
  7. if(Functions.isWindows()) return -1;
  8. return PosixAPI.jnr().stat(f.getPath()).mode();
  9. }

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

  1. private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException {
  2. File file = new File(filename);
  3. FileStat stat = runtime.getPosix().stat(filename);
  4. if (extension.length() > 0) {
  5. file.renameTo(new File(filename + extension));
  6. } else {
  7. file.delete();
  8. }
  9. createNewFile(file);
  10. runtime.getPosix().chmod(filename, stat.mode());
  11. runtime.getPosix().chown(filename, stat.uid(), stat.gid());
  12. runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(),
  13. new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK));
  14. }

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

  1. public static IRubyObject rowned_p(IRubyObject recv, IRubyObject filename) {
  2. Ruby runtime = recv.getRuntime();
  3. JRubyFile file = file(filename);
  4. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isROwned());
  5. }

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

  1. @JRubyMethod(name = "executable_real?", required = 1, module = true)
  2. public static IRubyObject executable_real_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutableReal());
  6. }

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

  1. @JRubyMethod(name = "executable?", required = 1, module = true)
  2. public static IRubyObject executable_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutable());
  6. }

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

  1. @JRubyMethod(name = "sticky?", required = 1, module = true)
  2. public static IRubyObject sticky_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSticky());
  6. }

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

  1. @JRubyMethod(name = "blockdev?", required = 1, module = true)
  2. public static IRubyObject blockdev_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isBlockDev());
  6. }

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

  1. @JRubyMethod(name = "pipe?", required = 1, module = true)
  2. public static IRubyObject pipe_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isNamedPipe());
  6. }

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

  1. @JRubyMethod(name = "setgid?", required = 1, module = true)
  2. public static IRubyObject setgid_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetgid());
  6. }

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

  1. @JRubyMethod(name = "socket?", required = 1, module = true)
  2. public static IRubyObject socket_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSocket());
  6. }

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

  1. @JRubyMethod(name = "chardev?", required = 1, module = true)
  2. public static IRubyObject chardev_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isCharDev());
  6. }

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

  1. @JRubyMethod(name = "owned?", required = 1, module = true)
  2. public static IRubyObject owned_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isOwned());
  6. }

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

  1. @JRubyMethod(name = "setuid?", required = 1, module = true)
  2. public static IRubyObject setuid_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetuid());
  6. }

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

  1. @JRubyMethod(name = "grpowned?", required = 1, module = true)
  2. public static IRubyObject grpowned_p(IRubyObject recv, IRubyObject filename) {
  3. Ruby runtime = recv.getRuntime();
  4. JRubyFile file = file(filename);
  5. // JRUBY-4446, grpowned? always returns false on Windows
  6. if (Platform.IS_WINDOWS) {
  7. return runtime.getFalse();
  8. }
  9. return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isGroupOwned());
  10. }

相关文章

POSIX类方法