java.io.File#canExecute ( )源码实例Demo

下面列出了java.io.File#canExecute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android   文件: VPNLaunchHelper.java
static private String writeMiniVPN(Context context) {
       String[] abis;
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
           abis = getSupportedAbisLollipop();
       else
           abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};

       for (String abi: abis) {

           File mvpnout = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
           if ((mvpnout.exists() && mvpnout.canExecute()) || writeMiniVPNBinary(context, abi, mvpnout)) {
               return mvpnout.getPath();
           }
       }

       return null;
}
 
源代码2 项目: Cake-VPN   文件: VPNLaunchHelper.java
private static String writeMiniVPN(Context context) {
    String[] abis;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) abis = getSupportedABIsLollipop();
    else
        //noinspection deprecation
        abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
    String nativeAPI = NativeUtils.getNativeAPI();
    if (!nativeAPI.equals(abis[0])) {
        VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
        abis = new String[]{nativeAPI};
    }
    for (String abi : abis) {
        File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
        if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
            return vpnExecutable.getPath();
        }
    }
    return null;
}
 
源代码3 项目: aCute   文件: DebuggersRegistry.java
public static DebuggerInfo getDefaultDebugger() {
	URL netcoredbgUrl = FileLocator.find(AcutePlugin.getDefault().getBundle(), new Path("netcoredbg")); //$NON-NLS-1$
	if (netcoredbgUrl != null) {
		try {
			netcoredbgUrl = FileLocator.toFileURL(netcoredbgUrl);
			File dbgDir = new File(netcoredbgUrl.toURI().normalize()).getAbsoluteFile();
			if (!dbgDir.canExecute() && dbgDir.canExecute()) {
				Files.setPosixFilePermissions(dbgDir.toPath(), Collections.singleton(PosixFilePermission.OWNER_EXECUTE));
			}
			return new DebuggerInfo(new File(dbgDir,Platform.OS_WIN32.equals(Platform.getOS()) ? "netcoredbg.exe" : "netcoredbg"), Collections.singletonList("--interpreter=vscode")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		} catch (IOException | URISyntaxException ex) {
			AcutePlugin.logError(ex);
		}
	}
	return new DebuggerInfo(new File("/home/mistria/apps/netcoredbg-linux-master/netcoredbg/netcoredbg"), Collections.singletonList("--interpreter=vscode")); //$NON-NLS-1$ //$NON-NLS-2$
}
 
源代码4 项目: testcontainers-java   文件: CommandLine.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;
}
 
源代码5 项目: binnavi   文件: CActionProvider.java
/**
 * Prompts the user for the location of the IDA executable.
 * 
 * @param parent Parent component used to display dialogs.
 * @param initialDirectory The directory to select by default.
 * 
 * @return The selected IDA executable or null if no executable was selected.
 */
public static String selectIDADirectory(final Component parent, final String initialDirectory) {
  Preconditions.checkNotNull(parent, "IE02067: Parent argument can not be null");
  Preconditions.checkNotNull(initialDirectory, "IE02259: Initial directory can not be null");

  final CIdaSelectionDialog dialog =
      CIdaSelectionDialog.show(SwingUtilities.getWindowAncestor(parent), initialDirectory);

  final File selectedFile = dialog.getSelectedFile();

  if (selectedFile == null) {
    return null;
  } else if (!selectedFile.exists()) {
    CMessageBox.showError(parent, "File does not exist.");

    return null;
  } else if (selectedFile.canExecute()) {
    return selectedFile.getAbsolutePath();
  } else {
    CMessageBox.showError(parent, "File is not an executable file.");

    return null;
  }
}
 
源代码6 项目: JavaExercises   文件: FileManager.java
public Object getValueAt(int row, int column) {
    File file = files[row];
    switch (column) {
        case 0:
            return fileSystemView.getSystemIcon(file);
        case 1:
            return fileSystemView.getSystemDisplayName(file);
        case 2:
            return file.getPath();
        case 3:
            return file.length();
        case 4:
            return file.lastModified();
        case 5:
            return file.canRead();
        case 6:
            return file.canWrite();
        case 7:
            return file.canExecute();
        default:
            System.err.println("Logic Error");
    }
    return "";
}
 
源代码7 项目: SimpleExplorer   文件: Permissions.java
public static String getBasicPermission(File file) {
    String per = "";

    per += file.isDirectory() ? "d" : "-";
    per += file.canRead() ? "r" : "-";
    per += file.canWrite() ? "w" : "-";
    per += file.canExecute() ? "x" : "-";

    return per;
}
 
源代码8 项目: synopsys-detect   文件: SimpleExecutableFinder.java
@Nullable
public File findExecutable(final String executable, final List<File> locations) {
    final List<String> executables = executablesFromName(executable);

    for (final File location : locations) {
        for (final String possibleExecutable : executables) {
            final File foundFile = fileFinder.findFile(location, possibleExecutable);
            if (foundFile != null && foundFile.exists() && foundFile.canExecute()) {
                return foundFile;
            }
        }
    }

    return null;
}
 
源代码9 项目: geowave   文件: KuduLocal.java
private boolean isInstalled() {
  final File kuduMasterBinary = new File(kuduLocalDir, KUDU_MASTER);
  final File kuduTabletBinary = new File(kuduLocalDir, KUDU_TABLET);
  final boolean okMaster = kuduMasterBinary.exists() && kuduMasterBinary.canExecute();
  final boolean okTablet = kuduTabletBinary.exists() && kuduTabletBinary.canExecute();
  return okMaster && okTablet;
}
 
源代码10 项目: hottub   文件: RunpathTest.java
final String findElfReader() {
    String[] paths = {"/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/ccs/bin"};
    final String cmd = isSolaris ? "elfdump" : "readelf";
    for (String x : paths) {
        File p = new File(x);
        File e = new File(p, cmd);
        if (e.canExecute()) {
            return e.getAbsolutePath();
        }
    }
    System.err.println("Warning: no suitable elf reader!");
    return null;
}
 
源代码11 项目: BashSupport   文件: BashInterpreterDetection.java
public boolean isSuitable(String guessLocation) {
    if (guessLocation == null) {
        return false;
    }

    File f = new File(guessLocation);
    return f.isFile() && f.canRead() && f.canExecute();
}
 
源代码12 项目: WIFIADB   文件: RootPresenter.java
public void chooseADBPath(@NotNull VirtualFile vFile) {
    final File adbFile = findADB(vFile);

    if (adbFile == null || !adbFile.canExecute() || !adbFile.getName().equalsIgnoreCase("adb")) {
        fail2FindADB();
    } else {
        checkAdbAvailable(adbFile);
    }
}
 
源代码13 项目: mzmine2   文件: Rdaemon.java
static void setRecursiveExecutable(File path) {
  for (File f : path.listFiles()) {
    if (f.isDirectory()) {
      f.setExecutable(true);
      setRecursiveExecutable(f);
    } else if (!f.canExecute() && (f.getName().endsWith(".so") || f.getName().endsWith(".dll"))) {
      f.setExecutable(true);
    }
  }

}
 
源代码14 项目: GreenDamFileExploere   文件: AudioInfoDialog.java
private void setReadWrite(File file) {
    StringBuilder builder = new StringBuilder();
    if (file.canRead()) {
        builder.append("可读");
    }
    if (file.canWrite()) {
        if (builder.length() > 0) {
            builder.append("/可写");
        } else {
            builder.append("可写");
        }
    }

    if (file.canExecute()) {
        if (file.isFile()) {
            if (builder.length() > 0) {
                builder.append("/可执行");
            } else {
                builder.append("可执行");
            }
        } else if (file.isDirectory()) {
            if (builder.length() > 0) {
                builder.append("/可进入");
            } else {
                builder.append("可进入");
            }
        }
    }

    if (builder.length() == 0) {
        builder.append("无权限");
    }
    mTvAudioInfoReadWrite.setText(builder.toString());
}
 
源代码15 项目: Repeat   文件: IPCClientService.java
public void setExecutingProgram(File executablePath) {
	if (!executablePath.canExecute()) {
		LOGGER.warning("File is not executable: " + executablePath.getAbsolutePath());
		return;
	}

	this.executingProgram = executablePath;
}
 
源代码16 项目: netbeans   文件: RunnerJava.java
/**
 * Constructs path to Java VM executable and verifies if it exists.
 * <p/>
 * @param server Payara server entity object.
 * @param command lassFish server administration command with local Java VM.
 * @return Path to Java VM executable
 */
private static String getJavaVM(final PayaraServer server,
        final CommandJava command) {
    final String METHOD = "getJavaVM";
    String javaVmExe = JavaUtils.javaVmExecutableFullPath(command.javaHome);
    File javaVmFile = new File(javaVmExe);
    // Java VM executable should exist and should be executable.
    if (!javaVmFile.canExecute()) {
        LOGGER.log(Level.INFO, METHOD, "noJavaVMExe", javaVmExe);
        return null;
    }
    return javaVmExe;
}
 
源代码17 项目: stratosphere   文件: WebInterfaceServer.java
/**
 * Checks and creates the directory described by the abstract directory path. This function checks
 * if the directory exists and creates it if necessary. It also checks read permissions and
 * write permission, if necessary.
 * 
 * @param dir
 *        The String describing the directory path.
 * @param needWritePermission
 *        A flag indicating whether to check write access.
 * @throws IOException
 *         Thrown, if the directory could not be created, or if one of the checks failed.
 */
private final void checkAndCreateDirectories(File f, boolean needWritePermission) throws IOException {
	String dir = f.getAbsolutePath();

	// check if it exists and it is not a directory
	if (f.exists() && !f.isDirectory()) {
		throw new IOException("A none directory file with the same name as the configured directory '" + dir
			+ "' already exists.");
	}

	// try to create the directory
	if (!f.exists()) {
		if (!f.mkdirs()) {
			throw new IOException("Could not create the directory '" + dir + "'.");
		}
	}

	// check the read and execute permission
	if (!(f.canRead() && f.canExecute())) {
		throw new IOException("The directory '" + dir + "' cannot be read and listed.");
	}

	// check the write permission
	if (needWritePermission && !f.canWrite()) {
		throw new IOException("No write access could be obtained on directory '" + dir + "'.");
	}
}
 
源代码18 项目: actframework   文件: ServerBootstrapClassLoader.java
private boolean verifyDir(File dir) {
    return dir.exists() && dir.canExecute() && dir.isDirectory();
}
 
源代码19 项目: gemfirexd-oss   文件: CF6Impl.java
public boolean canExecute(File file) {
  return file.canExecute();
}
 
源代码20 项目: Intellij-Plugin   文件: GaugeUtil.java
private static boolean isValidGaugeExec(File file) {
    return file.exists() && file.isFile() && file.canExecute();
}