public static Path hadoopFsPath(String fname, final Configuration conf, String user)
    throws URISyntaxException, IOException, InterruptedException {
    if (fname == null || conf == null) {
      return null;
    }

    UserGroupInformation ugi;
    if (user!=null) {
      ugi = UgiFactory.getUgi(user);
    } else {
      ugi = UserGroupInformation.getLoginUser();
    }
    final String finalFName = new String(fname);

    final FileSystem defaultFs =
        ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
          @Override
          public FileSystem run()
            throws URISyntaxException, IOException, InterruptedException {
            return FileSystem.get(new URI(finalFName), conf);
          }
        });

    fname = addUserHomeDirectoryIfApplicable(fname, user);
    URI u = new URI(fname);
    Path p = new Path(u).makeQualified(defaultFs);

    if (hadoopFsIsMissing(defaultFs, p))
      throw new FileNotFoundException("File " + fname + " does not exist.");

    FileSystem.closeAllForUGI(ugi);
    return p;
  }
@return true iff we are sure the file is not there.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonUtils.java