本文整理了Java中java.nio.file.Files.isExecutable()
方法的一些代码示例,展示了Files.isExecutable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.isExecutable()
方法的具体详情如下:
包路径:java.nio.file.Files
类名称:Files
方法名:isExecutable
暂无
代码示例来源:origin: org.assertj/assertj-core
public boolean isExecutable(Path path) {
return Files.isExecutable(path);
}
代码示例来源:origin: joel-costigliola/assertj-core
public boolean isExecutable(Path path) {
return Files.isExecutable(path);
}
代码示例来源:origin: org.apache.ant/ant
public boolean isSelected(File basedir, String filename, File file) {
return file != null && Files.isExecutable(file.toPath());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Checks if a storage directory path is accessible.
*
* @param path the given path
* @return true if path exists, false otherwise
*/
public static boolean isStorageDirAccessible(String path) {
Path filePath = Paths.get(path);
return Files.exists(filePath)
&& Files.isReadable(filePath)
&& Files.isWritable(filePath)
&& Files.isExecutable(filePath);
}
代码示例来源:origin: testcontainers/testcontainers-java
/**
* Check whether an executable exists, either at a specific path (if a full path is given) or
* on the PATH.
*
* @param executable the name of an executable on the PATH or a complete path to an executable that may/may not exist
* @return whether the executable exists and is executable
*/
public static boolean executableExists(String executable) {
// First check if we've been given the full path already
File directFile = new File(executable);
if (directFile.exists() && directFile.canExecute()) {
return true;
}
for (String pathString : getSystemPath()) {
Path path = Paths.get(pathString);
if (Files.exists(path.resolve(executable)) && Files.isExecutable(path.resolve(executable))) {
return true;
}
}
return false;
}
代码示例来源:origin: testcontainers/testcontainers-java
private int getUnixFileMode(final String pathAsString) {
final Path path = Paths.get(pathAsString);
if (this.forcedFileMode != null) {
return this.getModeValue(path);
}
try {
return (int) Files.getAttribute(path, "unix:mode");
} catch (IOException | UnsupportedOperationException e) {
// fallback for non-posix environments
int mode = DEFAULT_FILE_MODE;
if (Files.isDirectory(path)) {
mode = DEFAULT_DIR_MODE;
} else if (Files.isExecutable(path)) {
mode |= 0111; // equiv to +x for user/group/others
}
return mode;
}
}
代码示例来源:origin: google/bundletool
/** Checks whether the given path denotes an executable file. */
public static void checkFileExistsAndExecutable(Path path) {
checkArgument(Files.exists(path), "File '%s' was not found.", path);
checkArgument(Files.isExecutable(path), "File '%s' is not executable.", path);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public File findHook(Repository repository, String hookName) {
final File gitdir = repository.getDirectory();
if (gitdir == null) {
return null;
}
final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
.resolve(hookName);
if (Files.isExecutable(hookPath))
return hookPath.toFile();
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public File findHook(Repository repository, String hookName) {
final File gitdir = repository.getDirectory();
if (gitdir == null) {
return null;
}
final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
.resolve(hookName);
if (Files.isExecutable(hookPath))
return hookPath.toFile();
return null;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Whether the given file can be executed.
*
* @param file
* a {@link java.io.File} object.
* @return {@code true} if the given file can be executed.
* @since 4.1
*/
public static boolean canExecute(File file) {
if (!isFile(file)) {
return false;
}
return Files.isExecutable(file.toPath());
}
代码示例来源:origin: google/bundletool
/** Tries to locate adb utility under "platform-tools". */
public Optional<Path> locateAdb(Path sdkDir) {
Path platformToolsDir = sdkDir.resolve("platform-tools");
if (!Files.isDirectory(platformToolsDir)) {
return Optional.empty();
}
// Expecting to find one entry.
try (Stream<Path> pathStream =
Files.find(
platformToolsDir,
/* maxDepth= */ 1,
(path, attributes) -> adbPathMatcher.matches(path) && Files.isExecutable(path))) {
return pathStream.findFirst();
} catch (IOException e) {
throw CommandExecutionException.builder()
.withCause(e)
.withMessage("Error while trying to locate adb in SDK dir '%s'.", sdkDir)
.build();
}
}
}
代码示例来源:origin: groboclown/p4ic4idea
@Override
public boolean canExecute(String fileName) {
return Files.isExecutable(Paths.get(fileName));
}
代码示例来源:origin: com.perforce/p4java
@Override
public boolean canExecute(String fileName) {
return Files.isExecutable(Paths.get(fileName));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean isExecutable() {
return Files.isExecutable(Paths.get(path));
}
}
代码示例来源:origin: perlundq/yajsync
public static boolean isExecutable(String commandName)
{
for (String dirName : System.getenv("PATH").split(":")) {
Path p = Paths.get(dirName).resolve(commandName);
if (Files.isRegularFile(p) && Files.isExecutable(p)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
/**
* @param file
* @return {@code true} if the given file can be executed
* @since 4.1
*/
public static boolean canExecute(File file) {
if (!isFile(file)) {
return false;
}
return Files.isExecutable(file.toPath());
}
代码示例来源:origin: ferstl/depgraph-maven-plugin
private String determineDotExecutable() throws IOException {
if (this.dotExecutable == null) {
return "dot";
}
Path dotExecutablePath = this.dotExecutable.toPath();
if (!Files.exists(dotExecutablePath)) {
throw new NoSuchFileException("The dot executable '" + this.dotExecutable + "' does not exist.");
} else if (Files.isDirectory(dotExecutablePath) || !Files.isExecutable(dotExecutablePath)) {
throw new IOException("The dot executable '" + this.dotExecutable + "' is not a file or cannot be executed.");
}
return dotExecutablePath.toAbsolutePath().toString();
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
// No nonexistant paths are executable
public void isExecutableNonexistant() throws IOException {
final String path = "path";
Assert.assertFalse(Files.isExecutable(fs.getPath(path)));
}
代码示例来源:origin: org.apache.flink/flink-runtime
@Override
public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs) throws IOException {
java.nio.file.Path relativePath = sourceRoot.relativize(file);
ContainerSpecification.Artifact.Builder artifact = ContainerSpecification.Artifact.newBuilder()
.setSource(new Path(file.toUri()))
.setDest(new Path(targetPath, relativePath.toString()))
.setExecutable(Files.isExecutable(file))
.setCachable(true)
.setExtract(false);
env.getArtifacts().add(artifact.build());
return super.visitFile(file, attrs);
}
});
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
// All paths are executable
public void isExecutable() throws IOException {
final String path = "path";
this.getArchive().add(EmptyAsset.INSTANCE, path);
Assert.assertTrue(Files.isExecutable(fs.getPath(path)));
}
内容来源于网络,如有侵权,请联系作者删除!