Java File Attribute ensureExecutable(IPath path)

Here you can find the source of ensureExecutable(IPath path)

Description

ensure Executable

License

Open Source License

Declaration

public static void ensureExecutable(IPath path) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import org.eclipse.core.runtime.IPath;

public class Main {
    public static void ensureExecutable(IPath path) {
        if (pathExists(path)) {
            File file = path.toFile();

            if (!file.canExecute()) {
                if (!file.setExecutable(true)) {
                    file.setExecutable(true, true);
                }/*ww  w  . ja  v  a  2s . c  om*/
            }
        }
    }

    public static boolean pathExists(IPath path) {
        if (path == null || path.isEmpty()) {
            return false;
        }

        File file = path.toFile();

        return file.exists();
    }
}

Related

  1. checkIfExecutableIsInPATH(final String executableName)
  2. doesExecutableExist(String executablePath)
  3. ensureExecutable(final File file)
  4. ensureFileIsExecutable(String filename)
  5. fileExecute(String path)
  6. findInPath(String executable, String path, String pathSeparator)
  7. findJavaCompilerExecutableInDir(File dir)