private static Path getMatchingPath(Map<Path, List<String>> pathToAliases, Path dir) {
    // First find the path to be searched
    Path path = dir;
    if (foundAlias(pathToAliases, path)) {
      return path;
    }

    Path dirPath = Path.getPathWithoutSchemeAndAuthority(dir);
    if (foundAlias(pathToAliases, dirPath)) {
      return dirPath;
    }

    while (path!=null && dirPath!=null) {
      path=path.getParent();
      dirPath=dirPath.getParent();
      //first try full match
      if (foundAlias(pathToAliases, path)) {
        return path;
      }
      if (foundAlias(pathToAliases, dirPath)) {
        return dirPath;
      }
    }
    return null;
  }
Checks if files are in same format as the given input format.

Note: an empty set of files is considered compliant.
ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java