org.apache.hadoop.fs.FileUtil.makeShellPath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.apache.hadoop.fs.FileUtil.makeShellPath()方法的一些代码示例,展示了FileUtil.makeShellPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.makeShellPath()方法的具体详情如下:
包路径:org.apache.hadoop.fs.FileUtil
类名称:FileUtil
方法名:makeShellPath

FileUtil.makeShellPath介绍

[英]Convert a os-native filename to a path that works for the shell.
[中]将操作系统本机文件名转换为适用于shell的路径。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
 String[] linkCount(File file) 
 throws IOException {
  String[] buf = new String[getLinkCountCommand.length];
  System.arraycopy(getLinkCountCommand, 0, buf, 0, 
           getLinkCountCommand.length);
  buf[getLinkCountCommand.length - 1] = FileUtil.makeShellPath(file, true);
  return buf;
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @param makeCanonicalPath
 *          Whether to make canonical path for the file passed
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file, boolean makeCanonicalPath)
throws IOException {
 if (makeCanonicalPath) {
  return makeShellPath(file.getCanonicalPath());
 } else {
  return makeShellPath(file.toString());
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell
 * and avoids script injection attacks.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeSecureShellPath(File file) throws IOException {
 if (Shell.WINDOWS) {
  // Currently it is never called, but it might be helpful in the future.
  throw new UnsupportedOperationException("Not implemented for Windows");
 } else {
  return makeShellPath(file, false).replace("'", "'\\''");
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Use the command chmod to set permission.
 */
@Override
public void setPermission(Path p, FsPermission permission)
 throws IOException {
 if (NativeIO.isAvailable()) {
  NativeIO.POSIX.chmod(pathToFile(p).getCanonicalPath(),
          permission.toShort());
 } else {
  String perm = String.format("%04o", permission.toShort());
  Shell.execCommand(Shell.getSetPermissionCommand(perm, false,
   FileUtil.makeShellPath(pathToFile(p), true)));
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: io.hops/hadoop-common

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

/**
 * Convert a os-native filename to a path that works for the shell.
 * @param file The filename to convert
 * @return The unix pathname
 * @throws IOException on windows, there can be problems with the subprocess
 */
public static String makeShellPath(File file) throws IOException {
 return makeShellPath(file, false);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

@Override
String[] linkOne(File file, File linkName) 
throws IOException {
 String[] buf = hardLinkCommand.get();
 //unix wants argument order: "ln <existing> <new>"
 buf[buf.length-2] = FileUtil.makeShellPath(file, true); 
 buf[buf.length-1] = FileUtil.makeShellPath(linkName, true);
 return buf;
}

代码示例来源:origin: io.hops/hadoop-common

@Override
 String[] linkCount(File file) 
 throws IOException {
  String[] buf = new String[getLinkCountCommand.length];
  System.arraycopy(getLinkCountCommand, 0, buf, 0, 
           getLinkCountCommand.length);
  buf[getLinkCountCommand.length - 1] = FileUtil.makeShellPath(file, true);
  return buf;
 }
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
 String[] linkCount(File file) 
 throws IOException {
  String[] buf = new String[getLinkCountCommand.length];
  System.arraycopy(getLinkCountCommand, 0, buf, 0, 
           getLinkCountCommand.length);
  buf[getLinkCountCommand.length - 1] = FileUtil.makeShellPath(file, true);
  return buf;
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Override
 String[] linkCount(File file) 
 throws IOException {
  String[] buf = new String[getLinkCountCommand.length];
  System.arraycopy(getLinkCountCommand, 0, buf, 0, 
           getLinkCountCommand.length);
  buf[getLinkCountCommand.length - 1] = FileUtil.makeShellPath(file, true);
  return buf;
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
 String[] linkCount(File file) 
 throws IOException {
  String[] buf = new String[getLinkCountCommand.length];
  System.arraycopy(getLinkCountCommand, 0, buf, 0, 
           getLinkCountCommand.length);
  buf[getLinkCountCommand.length - 1] = FileUtil.makeShellPath(file, true);
  return buf;
 }
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

@Override
String[] linkCount(File file) 
throws IOException {
 String[] buf = getLinkCountCommand.get();
 buf[buf.length - 1] = FileUtil.makeShellPath(file, true);
 return buf;
}

代码示例来源:origin: org.gluster/glusterfs-hadoop

public static String execCommand(File f,String...cmd) throws IOException{
  String[] args=new String[cmd.length+1];
  System.arraycopy(cmd, 0, args, 0, cmd.length);
  args[cmd.length]=FileUtil.makeShellPath(f, true);
  String output=Shell.execCommand(args);
  return output;
}

代码示例来源:origin: gluster/glusterfs-hadoop

public static String execCommand(File f,String...cmd) throws IOException{
  String[] args=new String[cmd.length+1];
  System.arraycopy(cmd, 0, args, 0, cmd.length);
  args[cmd.length]=FileUtil.makeShellPath(f, true);
  String output=Shell.execCommand(args);
  return output;
}

代码示例来源:origin: apache/hama

public static List<String> captureOutAndErrorTee(List<String> setup,
  List<String> cmd, File stdoutFilename, File stderrFilename,
  long tailLength) throws IOException {
 String stdout = FileUtil.makeShellPath(stdoutFilename);
 List<String> result = new ArrayList<String>(3);
 result.add(bashCommand);
 result.add("-c");
 StringBuilder mergedCmd = new StringBuilder();
 mergedCmd.append(addCommand(cmd, true));
 mergedCmd.append(" 2>&1 | tee ").append(stdout);
 result.add(mergedCmd.toString());
 return result;
}

相关文章