生成二维码文件

@param string $content  二维码内容
@param string $fileName 文件名

@return bool
162568
public function save($content, $fileName) {
        $this->renderer = new Png();
        $this->renderer->setHeight($this->width);
        $this->renderer->setWidth($this->height);
        $writer = new Writer($this->renderer);

        $writer->writeFile($content, $fileName);

        return true;
    }
756678
private function getFile($directory, $content)
    {
        $hash = \md5($content);

        if (!\array_key_exists($hash, $this->files)) {
            $file = \tempnam($directory, '');
            $this->fs->dumpFile($file, $content);
            $this->files[$hash] = \basename($file);
        }

        return $this->files[$hash];
    }
1097522
public static function writeFile($fileName, $content, $flags = 0)
    {
        if (Coroutine::isIn()) {
            return Coroutine::writeFile($fileName, $content, $flags);
        } else {
            return false !== file_put_contents($fileName, $content, $flags);
        }
    }
1141216
public function put($file, $content)
    {
        $file = $this->path($file);

        $dirname = dirname($file);

        $this->makeDirectory($dirname);

        return file_put_contents($file, $content);
    }
264239
public static function writeFile($file, $content) {
		if (!@is_file($file)) {
			$changePermissions = TRUE;
		}

		if ($fd = fopen($file, 'wb')) {
			$res = fwrite($fd, $content);
			fclose($fd);

			if ($res === FALSE) {
				return FALSE;
			}

			if ($changePermissions) { // Change the permissions only if the file has just been created
				self::fixPermissions($file);
			}

			return TRUE;
		}

		return FALSE;
	}
700012
protected function writeAtomic($filename, $content, $mode) {
        $temp = tempnam(dirname($filename), 'atomic');

        if (!($fp = @fopen($temp, 'wb'))) {
            $temp = dirname($filename) . '/' . uniqid('atomic');
            if (!($fp = @fopen($temp, 'wb'))) {
                trigger_error(__METHOD__." : error writing temporary file '{$temp}'", E_USER_WARNING);
                return false;
            }
        }

        $br = fwrite($fp, $content);
        fclose($fp);
        if (!$br || $br != strlen($content)) {
            unlink($temp);
            return false;
        }

        chmod($temp, $mode);

        if (!rename($temp, $filename)) {
            unlink($filename);
            rename($temp, $filename);
        }
        return true;
    }
825248
protected function _encodeFile( $fileName, $data )
    {
        $_filePath = dirname( $fileName );

        if ( !is_dir( $_filePath ) )
        {
            if ( false === @mkdir( $_filePath, 0777, true ) && !is_dir( $_filePath ) )
            {
                return false;
            }
        }
        elseif ( !is_writable( $_filePath ) )
        {
            return false;
        }

        $_tempFile = tempnam( $_filePath, basename( $fileName ) );

        if ( false !== file_put_contents( $_tempFile, json_encode( $data ) ) && @rename( $_tempFile, $fileName ) )
        {
            @chmod( $fileName, 0666 & ~umask() );

            return true;
        }

        return false;
    }
631821
protected function write($content): bool
    {
        if ($content === false || $content === null) {
            return false;
        }

        return \is_resource($content)
            ? $this->filesystem->putStream($this->path, $content)
            : $this->filesystem->put($this->path, $content);
    }
556401
public function appendToFile($filename, $content)
    {
        if (\is_array($content)) {
            @trigger_error(sprintf('Calling "%s()" with an array in the $content argument is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED);
        }

        $dir = \dirname($filename);

        if (!is_dir($dir)) {
            $this->mkdir($dir);
        }

        if (!is_writable($dir)) {
            throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
        }

        if (false === @file_put_contents($filename, $content, FILE_APPEND)) {
            throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
        }
    }
827537
protected function saveInCache($filename, $content)
    {
        if (empty($this->cacheDir) || ! is_dir($this->cacheDir) || ! is_writable($this->cacheDir)) {
            return false;
        }

        $content["_chk"] = filemtime($filename);

        file_put_contents(
            $this->cacheDir . DIRECTORY_SEPARATOR . basename($filename) . ".cache",
            "<?php return " . var_export($content, true) . ";"
        );

        return true;
    }
990388
static public function file($content, $filename = '')
    {
        if (isset(Loader::$callback['CacheFile'])) {
            return call_user_func_array(Loader::$callback['CacheFile'], func_get_args());
        }
        empty($filename) && $filename = md5($content) . '.' . self::getFileExt($content);
        if (self::check() && file_put_contents(self::$cachepath . $filename, $content)) {
            return self::$cachepath . $filename;
        }
        return false;
    }
337170
public function send($filename, $content)
    {
        $client = $this->getClient();
        $result = new SummaryResult();

        try {
            $zipContent = $this->compress($filename.'.xml', $content);
            $params = [
                'fileName' => $filename.'.zip',
                'contentFile' => $zipContent,
            ];
            $response = $client->call('sendSummary', ['parameters' => $params]);
            $result
                ->setTicket($response->ticket)
                ->setSuccess(true);
        } catch (\SoapFault $e) {
            $result->setError($this->getErrorFromFault($e));
        }

        return $result;
    }
1107694
private function addFromString($filename, $content)
    {
        $this->repository->addFromString($this->getInternalPath().$filename, $content);
    }
1227174
public static function write(string $filePath, string $content = '')
    {
        //如果存在同样的目录名，则不允许这样的文件名
        if (is_dir($filePath)) {
            throw new \InvalidArgumentException("Invalid file path. Some directory name is same as it.");
        }
        //如果目录不存在，创建目录
        $dir = dirname($filePath);
        if (!Dir::make($dir)) {
            throw new \InvalidArgumentException(
                sprintf("can not make the directory of '%s'", $dir)
            );
        }
        return file_put_contents($filePath, $content, LOCK_EX);
    }
189011
public function setFileRaw( string$key, string$contentType, string$content, string$fileName=null ):self
	{
		$this->files[$key]= [
			'fileName'=> $fileName??md5($content),
			'contentType'=> $contentType,
			'content'=> $content,
		];

		return $this;
	}
440645
private function createPublicCacheFile(string $fileName, string $content): string
    {
        $extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (empty($extension)) {
            $extension = 'cache';
        }

        $name = pathinfo($fileName, PATHINFO_FILENAME);
        $checksum = sha1($fileName . $content);
        $cacheFile = $this->directory . '/' . $name . '.' . $checksum . '.' . $extension;

        file_put_contents($cacheFile, $content);

        if ($this->chmod > -1) {
            chmod($cacheFile, $this->chmod);
        }

        return $cacheFile;
    }
785129
public function input($filename, $content)
    {
        $this->_currentFile = $filename;
        return preg_replace_callback(
            $this->_pattern,
            array($this, '_replace'),
            $content
        );
    }