本文整理了Java中jnr.posix.POSIX.stat()
方法的一些代码示例,展示了POSIX.stat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.stat()
方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:stat
暂无
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public int getFileSystemBlockSize(Path path) {
FileStat stat = posix.stat(path.toString());
return Math.toIntExact(stat.blockSize());
}
代码示例来源: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: com.facebook.presto.cassandra/cassandra-driver
public FileStat stat(String path) {
return posix().stat(path);
}
代码示例来源: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.jruby/jruby-complete
@Override
public FileStat stat() {
FileStat stat = posix.allocateStat();
return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public FileStat stat() {
FileStat stat = posix.allocateStat();
return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Gets the mode of a file/directory, if appropriate.
* @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;
return PosixAPI.jnr().stat(f.getPath()).mode();
}
代码示例来源: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
public static IRubyObject rowned_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isROwned());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "executable_real?", required = 1, module = true)
public static IRubyObject executable_real_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutableReal());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "executable?", required = 1, module = true)
public static IRubyObject executable_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutable());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "sticky?", required = 1, module = true)
public static IRubyObject sticky_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSticky());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "blockdev?", required = 1, module = true)
public static IRubyObject blockdev_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isBlockDev());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "pipe?", required = 1, module = true)
public static IRubyObject pipe_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isNamedPipe());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "setgid?", required = 1, module = true)
public static IRubyObject setgid_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetgid());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "socket?", required = 1, module = true)
public static IRubyObject socket_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSocket());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "chardev?", required = 1, module = true)
public static IRubyObject chardev_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isCharDev());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "owned?", required = 1, module = true)
public static IRubyObject owned_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isOwned());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "setuid?", required = 1, module = true)
public static IRubyObject setuid_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetuid());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "grpowned?", required = 1, module = true)
public static IRubyObject grpowned_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
// JRUBY-4446, grpowned? always returns false on Windows
if (Platform.IS_WINDOWS) {
return runtime.getFalse();
}
return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isGroupOwned());
}
内容来源于网络,如有侵权,请联系作者删除!