private static @NotNull Path getIndexDirectory(String indexName, String relativePath, boolean stubKey, boolean forVersion) throws IOException {
    indexName = Strings.toLowerCase(indexName);
    Path indexDir;
    if (stubKey) {
      // store StubIndices under StubUpdating index' root to ensure they are deleted
      // when StubUpdatingIndex version is changed
      indexDir = getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath).resolve(forVersion ? STUB_VERSIONS : indexName);
    }
    else {
      indexDir = PathManager.getIndexRoot();
      if (!relativePath.isEmpty()) {
        indexDir = indexDir.resolve(relativePath);
      }
      indexDir = indexDir.resolve(indexName);
    }
    if (!FileBasedIndex.USE_IN_MEMORY_INDEX) {
      // TODO should be created automatically with storages
      Files.createDirectories(indexDir);
    }
    return indexDir;
  }
private static @NotNull Path getIndexDirectory(String indexName, String relativePath, boolean stubKey, boolean forVersion)