List of usage examples for org.apache.hadoop.fs FileUtil canRead
public static boolean canRead(File f)
From source file:com.mellanox.r4h.MiniDFSCluster.java
License:Apache License
/** * @return a debug string which can help diagnose an error of why * a given directory might have a permissions error in the context * of a test case//from ww w . j a v a 2 s .c o m */ private String createPermissionsDiagnosisString(File path) { StringBuilder sb = new StringBuilder(); while (path != null) { sb.append("path '" + path + "': ").append("\n"); sb.append("\tabsolute:").append(path.getAbsolutePath()).append("\n"); sb.append("\tpermissions: "); sb.append(path.isDirectory() ? "d" : "-"); sb.append(FileUtil.canRead(path) ? "r" : "-"); sb.append(FileUtil.canWrite(path) ? "w" : "-"); sb.append(FileUtil.canExecute(path) ? "x" : "-"); sb.append("\n"); path = path.getParentFile(); } return sb.toString(); }
From source file:org.apache.slider.common.tools.SliderUtils.java
License:Apache License
/** * Check for any needed libraries being present. On Unix none are needed; * on windows they must be present// www.j a v a 2s.co m * @return true if all is well */ public static String checkForRequiredNativeLibraries() { if (!Shell.WINDOWS) { return ""; } StringBuilder errorText = new StringBuilder(""); if (!NativeIO.isAvailable()) { errorText.append("No native IO library. "); } try { String path = Shell.getQualifiedBinPath("winutils.exe"); log.debug("winutils is at {}", path); } catch (IOException e) { errorText.append("No WINUTILS.EXE. "); log.warn("No winutils: {}", e, e); } try { File target = new File("target"); FileUtil.canRead(target); } catch (UnsatisfiedLinkError e) { log.warn("Failing to link to native IO methods: {}", e, e); errorText.append("No native IO methods"); } return errorText.toString(); }