當前位置: 首頁>>代碼示例>>Java>>正文


Java Path.CUR_DIR屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.fs.Path.CUR_DIR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Path.CUR_DIR屬性的具體用法?Java Path.CUR_DIR怎麽用?Java Path.CUR_DIR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.fs.Path的用法示例。


在下文中一共展示了Path.CUR_DIR屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCurrentDir

public synchronized String getCurrentDir() {
    if (currentDir == null) {
        try {
            final Path path = new Path(Path.CUR_DIR);
            final FileSystem fs = getFileSystem();
            final FileStatus[] fileStatuses = fs.globStatus(path);
            if (fileStatuses == null || fileStatuses.length == 0) {
                return "";
            }
            homeDir = currentDir = fileStatuses[0].getPath().toUri().getPath();
        } catch (Exception e) {
            return "";
        }
    }
    return currentDir;
}
 
開發者ID:avast,項目名稱:hdfs-shell,代碼行數:16,代碼來源:ContextCommands.java

示例2: relativize

private static String relativize(URI cwdUri, URI srcUri, boolean isDir) {
  String uriPath = srcUri.getPath();
  String cwdPath = cwdUri.getPath();
  if (cwdPath.equals(uriPath)) {
    return Path.CUR_DIR;
  }

  // find common ancestor
  int lastSep = findLongestDirPrefix(cwdPath, uriPath, isDir);
  
  StringBuilder relPath = new StringBuilder();    
  // take the remaining path fragment after the ancestor
  if (lastSep < uriPath.length()) {
    relPath.append(uriPath.substring(lastSep+1));
  }

  // if cwd has a path fragment after the ancestor, convert them to ".."
  if (lastSep < cwdPath.length()) {
    while (lastSep != -1) {
      if (relPath.length() != 0) relPath.insert(0, Path.SEPARATOR);
      relPath.insert(0, "..");
      lastSep = cwdPath.indexOf(Path.SEPARATOR, lastSep+1);
    }
  }
  return relPath.toString();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:PathData.java

示例3: getLocalDestination

/**
 *  The last arg is expected to be a local path, if only one argument is
 *  given then the destination will be the current directory 
 *  @param args is the list of arguments
 */
protected void getLocalDestination(LinkedList<String> args)
throws IOException {
  String pathString = (args.size() < 2) ? Path.CUR_DIR : args.removeLast();
  try {
    dst = new PathData(new URI(pathString), getConf());
  } catch (URISyntaxException e) {
    if (Path.WINDOWS) {
      // Unlike URI, PathData knows how to parse Windows drive-letter paths.
      dst = new PathData(pathString, getConf());
    } else {
      throw new IOException("unexpected URISyntaxException", e);
    }
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:19,代碼來源:CommandWithDestination.java

示例4: getRemoteDestination

/**
 *  The last arg is expected to be a remote path, if only one argument is
 *  given then the destination will be the remote user's directory 
 *  @param args is the list of arguments
 *  @throws PathIOException if path doesn't exist or matches too many times 
 */
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
  if (args.size() < 2) {
    dst = new PathData(Path.CUR_DIR, getConf());
  } else {
    String pathString = args.removeLast();
    // if the path is a glob, then it must match one and only one path
    PathData[] items = PathData.expandAsGlob(pathString, getConf());
    switch (items.length) {
      case 0:
        throw new PathNotFoundException(pathString);
      case 1:
        dst = items[0];
        break;
      default:
        throw new PathIOException(pathString, "Too many matches");
    }
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:25,代碼來源:CommandWithDestination.java

示例5: testCwdContents

@Test (timeout = 30000)
public void testCwdContents() throws Exception {
  String dirString = Path.CUR_DIR;
  PathData item = new PathData(dirString, conf);
  PathData[] items = item.getDirectoryContents();
  assertEquals(
      sortedString("d1", "d2"),
      sortedString(items)
  );
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:10,代碼來源:TestPathData.java

示例6: getPathString

static String getPathString(byte[] path) {
  String pathStr = DFSUtil.bytes2String(path);
  if (pathStr.isEmpty()) {
    return Path.CUR_DIR;
  } else {
    return Path.CUR_DIR + Path.SEPARATOR + pathStr;
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:SnapshotDiffReport.java


注:本文中的org.apache.hadoop.fs.Path.CUR_DIR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。