public synchronized static File getTempFile(String name) throws IOException {
    if (myTempDir == null) {
      String path = System.getProperty("java.io.tmpdir");
      if (path == null) throw new IllegalArgumentException("System property `java.io.tmpdir` is not defined");

      Path dir = Path.of(path);
      if (!Files.isDirectory(dir)) throw new IOException("Not a directory: " + dir);

      if (REQUIRED_FREE_SPACE > 0) {
        FileStore fs = Files.getFileStore(dir);
        if (fs.getUsableSpace() < REQUIRED_FREE_SPACE) {
          throw new IOException("Not enough free space on '" + fs + "' (" + (REQUIRED_FREE_SPACE / 1_000_000) + " MB required");
        }
      }

      myTempDir = Files.createTempDirectory(dir, "idea.updater.files.").toFile();
      LOG.info("created a working directory: " + myTempDir);
    }

    File myTempFile;
    int index = 0;
    do {
      myTempFile = new File(myTempDir, name + ".tmp." + index++);
    }
    while (myTempFile.exists());
    return myTempFile;
  }
public synchronized static File getTempFile(String name)