static std::unique_ptr Create()

in tools/common/temp_file.h [74:90]


  static std::unique_ptr<TempDirectory> Create(
      const std::string &path_template) {
    const char *tmpDir = getenv("TMPDIR");
    if (!tmpDir) {
      tmpDir = "/tmp";
    }
    size_t size = strlen(tmpDir) + path_template.size() + 2;
    std::unique_ptr<char[]> path(new char[size]);
    snprintf(path.get(), size, "%s/%s", tmpDir, path_template.c_str());

    if (mkdtemp(path.get()) == nullptr) {
      std::cerr << "Failed to create temporary directory '" << path.get()
                << "': " << strerror(errno) << "\n";
      return nullptr;
    }
    return std::unique_ptr<TempDirectory>(new TempDirectory(path.get()));
  }