Create a randomly named temporary file.

@param string $suffix filename suffix
@throws \Exception
@return \SplFileInfo
540026
public function createTmpFile(string $suffix = ''): \SplFileInfo
    {
        $file = uniqid();
        if ($suffix) {
            $file .= '-' . $suffix;
        }
        return $this->createFile($file);
    }
257003
public PathImpl createTempFile(String prefix, String suffix) throws IOException
  {
    if (prefix == null || prefix.length () == 0)
      prefix = "t";

    if (suffix == null)
      suffix = ".tmp";

    synchronized (LOCK) {
      for (int i = 0; i < 32768; i++) {
        int r = Math.abs((int) RandomUtil.getRandomLong());
        PathImpl file = lookup(prefix + r + suffix);

        if (file.createNewFile())
          return file;
      }
    }

    throw new IOException("cannot create temp file");
  }
243904
public static function unique(string $prefix = '', string $suffix = ''): string
    {
        $unique = md5((string)mt_rand());
        if ($prefix !== '') {
            $unique = $prefix . $unique;
        }
        if ($suffix !== '') {
            $unique .= $suffix;
        }
        return $unique;
    }
782298
def create_temp_file(self, suffix, content):
        
        temp = tempfile.NamedTemporaryFile(suffix=suffix)
        temp.write(content.encode('latin1').decode('unicode_escape').encode('utf-8'))
        temp.seek(0) # Resets the temp file line to 0
        return temp
412828
public static function createTemporary($extension = NULL) {
    $tmpfile = tempnam(sys_get_temp_dir(), mb_substr(uniqid(),0,3));

    if ($extension) {
      rename($tmpfile, $tmpfile = $tmpfile.'.'.ltrim($extension, '.'));
    }

    return new static($tmpfile);
  }
586062
private function create()
    {
        $filename = tempnam(null === $this->tempDir ? sys_get_temp_dir() : $this->tempDir, 'php');

        if (!$filename) {
            throw new \Error('The function tempnam() could not create a file in temporary directory.');
        }

        return $filename;
    }
347606
public static function addSuffix(string $value, string $suffix): string
    {
        return self::removeSuffix($value, $suffix).$suffix;
    }
454837
public function dir()
    {
        $this->_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid($this->_prefix);
        if (!mkdir($this->_name)) {
            throw new \Exception('Cannot create temporary directory');
        }
        return $this;
    }
588181
public function endsWith($suffix) {
		$other = new Str($suffix, $this->charset);

		return mb_strrpos($this->rawString, $suffix, 0, $this->charset) === ($this->length() - $other->length());
	}
1072553
private function generateCode(int $length = 4, string $prefix = '', string $suffix = '')
    {
        for ($i = 0; $i < $length; $i++) {
            $prefix .= random_int(0, 1) ? chr(random_int(65, 90)) : random_int(0, 9);
        }

        return $prefix.$suffix;
    }
713900
public static function fromDirectory(string $directory, string $suffix = '.php'): ConfigInterface
    {
        $config = [];
        foreach (new \DirectoryIterator($directory) as $file) {
            if ($file->isDot()) {
                continue;
            }

            $suffixLen = strlen($suffix);
            if (! (substr($file->getFilename(), -$suffixLen) === $suffix)) {
                continue;
            }

            // get the file namespace like app.php will be app.
            $namespace = substr($file->getFilename(), 0, -($suffixLen));

            // create the file resolver so we can resolve the
            $config[$namespace] = new File($file->getPathname());
        }

        return new static($config);
    }
544471
public static RandomAccessFile createTemporaryFile
        (String prefix, String suffix) throws IOException {

        return createTemporaryFile(prefix, suffix, null);
    }
858530
public static FileChannel createTempFile(String prefix, String suffix) throws IOException {
        return createTempFile(TMPDIR, prefix, suffix);
    }
1065898
protected function createFileName($fileName)
    {
        return $this->parseFileName($fileName) . $this->suffix() . $this->config->fileExtension();
    }
502958
public function makeFile($mode = FileSystemPermission::NORMAL)
    {
        $fileId = $this->generateId();
        $filePath = sys_get_temp_dir() . '/' . $fileId;
        $file = new TemporaryFile($filePath, $mode);

        return $file;
    }
1097272
public static function createTempPathNamed($name)
    {
        $dir = static::createTempPath();

        if (!unlink($dir)) {
            // @codeCoverageIgnoreStart
            throw new FileException(
                'The temporary file could not be deleted.'
            );
        }
        // @codeCoverageIgnoreEnd

        if (!mkdir($dir)) {
            // @codeCoverageIgnoreStart
            throw new FileException(
                'A new temporary directory could not be created.'
            );
        }
        // @codeCoverageIgnoreEnd

        $path = $dir . DIRECTORY_SEPARATOR . $name;

        if (!touch($path)) {
            // @codeCoverageIgnoreStart
            throw new FileException(
                'A new temporary file could not be created.'
            );
        }
        // @codeCoverageIgnoreEnd

        return $path;
    }
357160
public function getPathByConvention($suffix = null)
    {
        if (empty($suffix)) {
            return sprintf('%s_nodes', $this->getBundleName());
        }

        return sprintf('%s_nodes_%s', $this->getBundleName(), $suffix);
    }