public static boolean createTableDescriptorForTableDirectory(FileSystem fs, Path tableDir,
    TableDescriptor htd, boolean forceCreation) throws IOException {
    Optional<Pair<FileStatus, TableDescriptor>> opt = getTableDescriptorFromFs(fs, tableDir, false);
    if (opt.isPresent()) {
      LOG.debug("Current path={}", opt.get().getFirst());
      if (!forceCreation) {
        if (htd.equals(opt.get().getSecond())) {
          LOG.trace("TableInfo already exists.. Skipping creation");
          return false;
        }
      }
    }
    return writeTableDescriptor(fs, htd, tableDir, opt.map(Pair::getFirst).orElse(null)) != null;
  }
Create a new TableDescriptor in HDFS in the specified table directory. Happens when we create a
new table snapshoting. Does not enforce read-only. That is for caller to determine.
@param fs            Filesystem to use.
@param tableDir      table directory under which we should write the file
@param htd           description of the table to write
@param forceCreation if <tt>true</tt>,then even if previous table descriptor is present it will
                     be overwritten
@return <tt>true</tt> if the we successfully created the file, <tt>false</tt> if the file
        already exists and we weren't forcing the descriptor creation.
@throws IOException if a filesystem error occurs
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java