private static String getPipeWALDirPath(File file) throws IOException {
    while (!file.getName().equals(IoTDBConstant.WAL_FOLDER_NAME)) {
      file = file.getParentFile();
    }

    return file.getParentFile().getCanonicalPath()
        + File.separator
        + IoTDBConstant.DATA_FOLDER_NAME
        + File.separator
        + PipeConfig.getInstance().getPipeHardlinkBaseDirName()
        + File.separator
        + PipeConfig.getInstance().getPipeHardlinkWALDirName();
  }
given a file, create a hardlink, maintain a reference count for the hardlink, and return the
hardlink.

<p>if the given file is already a hardlink, increase its reference count and return it.

<p>if the given file is a wal, create a hardlink in pipe dir, increase the reference count of
the hardlink and return it.

@param file wal file. can be original file or the hardlink of original file
@return the hardlink
@throws IOException when create hardlink failed
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/wal/hardlink/PipeWALHardlinkResourceManager.java