Example usage for java.io File canExecute

List of usage examples for java.io File canExecute

Introduction

In this page you can find the example usage for java.io File canExecute.

Prototype

public boolean canExecute() 

Source Link

Document

Tests whether the application can execute the file denoted by this abstract pathname.

Usage

From source file:org.geoserver.importer.transform.PostScriptTransform.java

private File getExecutable() {
    Resource scripts = getScriptsFolder();

    Resource resource = scripts.get(name);
    if (resource.getType() != Resource.Type.RESOURCE) {
        throw new ValidationException(
                "Script named '" + name + "' was not found in " + "$GEOSERVER_DATA_DIR/importer/scripts");
    }// w  w w.ja v a  2 s .  c o  m
    File executable = resource.file();
    if (!executable.canExecute()) {
        throw new ValidationException("Found file named '" + name + "' in "
                + "$GEOSERVER_DATA_DIR/importer/scripts, but it's not executable");
    }
    return executable;
}

From source file:com.ttech.cordovabuild.domain.built.ApplicationBuilderTest.java

@Test
public void checkCreateExistence() throws IOException, InterruptedException {
    File file = new File(createPath);
    assertTrue(file.exists());//from w ww .  j  ava 2  s  .  c  o m
    assertTrue(file.canExecute());
}

From source file:com.theaetetuslabs.android_apkmaker.AndroidApkMaker.java

private static File unpackAapt(Context context, File aapt) throws IOException {
    if (!aapt.exists()) {
        String aaptToUse = null;/*from   w w  w.j  av a  2  s .c  om*/
        boolean usePie = VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
        String abi;
        if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP) {
            String[] abis = Build.SUPPORTED_32_BIT_ABIS;
            for (String mAbi : abis) {
                aaptToUse = getAaptFlavor(mAbi, usePie);
                if (aaptToUse != null) {
                    break;
                }
            }
        } else {
            aaptToUse = getAaptFlavor(Build.CPU_ABI, usePie);
        }
        if (aaptToUse == null) {
            aaptToUse = "aapt-arm";
        }
        if (usePie) {
            aaptToUse += "-pie";
        }
        unpackAsset(context, aaptToUse, aapt);
    }
    if (!aapt.canExecute()) {
        aapt.setExecutable(true, true);
    }
    if (!aapt.canExecute()) {
        Runtime.getRuntime().exec("chmod 777 " + aapt.getAbsolutePath());
    }
    return aapt;
}

From source file:minium.web.config.services.DriverServicesProperties.java

protected File findExecutable(String exeName) {
    File driversDir = getDriversDir();
    if (driversDir == null)
        return null;

    String osSpecificExeName = Platform.getCurrent().is(Platform.WINDOWS) ? exeName + ".exe" : exeName;
    File exeFile = new File(driversDir, osSpecificExeName);

    return exeFile.exists() && exeFile.isFile() && exeFile.canExecute() ? exeFile : null;
}

From source file:org.apache.hcatalog.templeton.ExecServiceImpl.java

/**
 * Given a program name, lookup the fully qualified path.  Throws
 * an exception if the program is missing or not authorized.
 *
 * @param path      The path of the program.
 * @return The path of the validated program.
 *///from   w w w . ja v a  2  s. c o m
public String validateProgram(String path) throws NotAuthorizedException, IOException {
    File f = new File(path);
    if (f.canExecute()) {
        return f.getCanonicalPath();
    } else {
        throw new NotAuthorizedException("Unable to access program: " + path);
    }
}

From source file:org.echocat.jomon.process.local.daemon.LocalProcessDaemon.java

@Nonnull
protected File getBinaryOfEnvironmentVariable(@Nonnull String environmentVariableName, @Nonnull SubPath subPath,
        @Nonnull String binaryFileName) throws IOException {
    final File directory = getDirectoryOfEnvironmentVariable(environmentVariableName, subPath);
    File binary = new File(directory, binaryFileName);
    if (!binary.canExecute()) {
        binary = new File(directory, binaryFileName + ".exe");
        if (!binary.canExecute()) {
            throw new IllegalStateException("In the current environment points the " + environmentVariableName
                    + " environment variable to " + directory + " with no " + binaryFileName
                    + " executable in it.");
        }/*from   w  ww .j  a  v  a2 s  .  c om*/
    }
    return binary;
}

From source file:com.xse.eclipseui.widgets.validators.PathValidator.java

@Override
public IStatus validate(final String value) {
    final IStatus validationStatus = super.validate(value);

    if (validationStatus.isOK()) {
        if (!this.isMandatory() && StringUtils.isEmpty(value)) {
            return Status.OK_STATUS;
        }//from  www .j  a va2s  .c  om

        final File file = new File(value);
        if (this.isDirectory) {
            if (file.exists() && file.isDirectory() && file.canWrite()) {
                return Status.OK_STATUS;
            }
        } else {
            if (this.exists) {
                if (file.exists() && file.isFile() && file.canRead()) {
                    return Status.OK_STATUS;
                }
            } else {
                final String fullPathNoEndSeparator = FilenameUtils.getFullPathNoEndSeparator(value);
                if (fullPathNoEndSeparator != null) {
                    final File parentPath = new File(fullPathNoEndSeparator);
                    if (parentPath.exists() && parentPath.isDirectory() && parentPath.canExecute()
                            && parentPath.canWrite()) {
                        return Status.OK_STATUS;
                    }
                }
            }
        }

        return new Status(this.errorLevel, this.pluginId, this.getMessage());
    }

    return validationStatus;
}

From source file:com.gft.cordova.plugins.trustdevice.TrustedDevicePlugin.java

/**
 * Check su command in common paths./*  w ww . ja  v a 2 s.  c o  m*/
 *
 * @return true = su is present.
 */
public boolean isSuPresent() {
    String[] paths = { "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su",
            "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su" };

    for (String path : paths) {
        File suBinary = new File(path);
        // Glubs!!
        if (suBinary.canExecute())
            return true;
        // Current SuperUser apps don't have 'su' executable for your userID
        // The permissions are changed during few seconds on app request to SuperUser
        if (suBinary.exists())
            return true;
    }
    return false;
}

From source file:jfs.sync.encrypted.EncryptedFileStorageAccess.java

protected String filePermissionsString(File file) {
    return (file.canRead() ? "r" : "-") + (file.canWrite() ? "w" : "-") + (file.canExecute() ? "x" : "-");
}

From source file:org.bitbucket.mlopatkin.android.logviewer.ConfigurationDialog.java

private boolean validateData() {
    String filename = textAdbExecutable.getText();
    if (filename == null) {
        return false; // silently ignore
    }//from  ww w .ja va  2s.  c  o  m
    File f = new File(filename);
    if (Configuration.adb.DEFAULT_EXECUTABLE.equals(filename) || (f.exists() && f.canExecute())) {
        return true;
    }
    ErrorDialogsHelper.showError(this, "%s is not a valid adb file", filename);
    return false;
}