code: public String getBaseDirectory(String path) {
      if (path != null) {
        int finishIndex = path.indexOf(HADOOP_TEMPORARY);
        if (finishIndex > 0) {
          String newPath = path.substring(0, finishIndex);
          if (newPath.endsWith("/")) {
            return newPath.substring(0, newPath.length() - 1);
          }
          return newPath;
        }
      }
      return path;
    }
docs: Transform scheme://hostname/a/b/_temporary/0 into scheme://hostname/a/b/
  We mainly need this for mkdirs operations
  
  @param path input directory with temporary prefix
  @return modified directory without temporary prefix