Write data into file

@param string $strFilePath Path of the file into which to write
@param string $strContents The contents that should be written into the file

@throws \Exception
559546
public static function writeFile($strFilePath, $strContents)
    {
        $fileHandle = fopen($strFilePath, "w");
        if (!$fileHandle) {
            throw new \Exception("Cannot open file for writing: " . $strFilePath);
        }

        if (fwrite($fileHandle, $strContents, strlen($strContents)) === false) {
            throw new \Exception("Unable to write file: " . $strFilePath);
        }
        fclose($fileHandle);
    }
995398
public function writeCompressedFile($compressedFilepath, $filepath)
	{
		$filePointer = fopen($compressedFilepath, 'w');
		fwrite($filePointer, gzencode(file_get_contents($filepath), 9));
		fclose($filePointer);
	}
399123
public static function write($path, $content)
    {
        if (file_exists($path) && is_file($path) && !is_writable($path)) {
            return new PermissionDeniedException("$path is not writable");
        }

        $directory = dirname($path);

        if (!is_writable($directory)) {
            return new PermissionDeniedException("$directory is not writable");
        }

        file_put_contents($path, $content);
    }
830967
public static function writeFile($filePath, $fileData, $mode = 0600)
    {
        if (false === file_put_contents($filePath, $fileData)) {
            throw new RuntimeException(sprintf('unable to write file "%s"', $filePath));
        }
        if (false === chmod($filePath, $mode)) {
            throw new RuntimeException(sprintf('unable to set permissions on file "%s"', $filePath));
        }
    }
407320
public function put($path, $contents)
    {
        $directory = dirname($path);
        $this->createDir($directory);
        $path = $this->getPath($path);
        if (!file_exists($path) && !is_writable(dirname($path))) {
            throw new RuntimeException(dirname($path) . ' is not writable');
        }

        if (file_exists($path) && !is_writable($path)) {
            throw new RuntimeException($path . ' is not writable');
        }

        return file_put_contents($path, $contents);
    }
910766
public function write ($content)
	{
		$this->createPath($this->path);
		file_put_contents($this->getName(), $content, FILE_APPEND);
	}
813483
public function combineString( $path, $content, $throwException = FALSE )
	{
		$listLines	= array();
		$listImport	= array();
		$this->statistics['sizeOriginal']	= 0;
		$this->statistics['sizeCombined']	= 0;
		$this->statistics['sizeCompressed']	= 0;
		$this->statistics['numberFiles']	= 0;
		$this->statistics['filesFound']		= array();
		$this->statistics['filesSkipped']	= array();
		$content	= preg_replace( '/\/\*.+\*\//sU', '', $content );
		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			$line	= trim( $line );
			if( !$line )
				continue;
			if( preg_match( $this->importPattern, $line ) )
			{
				preg_match_all( $this->importPattern, $line, $matches );
				$fileName	= $matches[2][0];
				$this->statistics['filesFound'][]	= $fileName;

				if( !file_exists( $path.$fileName ) )
				{
					if( $throwException )
						throw new RuntimeException( 'CSS File "'.$fileName.'" is not existing.' );
					$this->statistics['filesSkipped'][] = $fileName;
					continue;
				}

				$content	= file_get_contents( $path.$fileName );
				$content	= $this->reviseStyle( $content );
				$this->statistics['numberFiles']	++;
				$this->statistics['sizeOriginal']	+= strlen( $content );
//			$depth	= substr
				if( substr_count( $fileName, "/" ) )
					$content	= preg_replace( "@(\.\./){1}([^\.])@i", "\\2", $content );
				$listImport[]	= "/*  --  ".$fileName."  --  */";
				$listImport[]	= $content."\n";
			}
			else
				$listLines[]	= $line;
		}
		$content	= implode( "\n", $listImport ).implode( "\n", $listLines );
		$this->statistics['sizeCombined']	= strlen( $content );
		return $content;
	}
263043
private static function createAndWriteFile(string $path, string $contents)
    {
        $fileHandle = fopen($path, 'wb');
        if ($fileHandle === false) {
            throw new \RuntimeException('The file "' . $path . '" could not be opened for writing.', 1519851153);
        }

        fwrite($fileHandle, $contents);
        fclose($fileHandle);
    }
797325
private function write($src, $fileName, $content)
    {

        if (!$this->file->exists($src)) {
            $this->file->makeDirectory($src);
        }
        $this->file->put($fileName, $content);
    }
146691
protected function writeFile($path)
    {
        $handle = fopen($path, Stream::MODE_READ_WRITE_RESET);

        if ($handle === false) {
            throw new \RuntimeException('Unable to write to path: ' . $path);
        }

        $this->stream->rewind();

        while (!$this->stream->eof()) {
            fwrite($handle, $this->stream->read(4096));
        }

        fclose($handle);
    }
379086
public function write(string $contents) : void
    {
        file_put_contents($this->filename, $contents);
        $this->timestamp = time();
    }
456722
public function write( string $formatOrContents, ...$contextValues ) : void
	{
		fwrite(
			$this->getFileHandle(),
			sprintf( $formatOrContents, ...$contextValues )
		);
	}
669220
protected void writeFile(String basename, byte[] content,
			Function2<? super File, ? super String, ? extends File> outputDirectoryFilter) {
		for (final String output : getOutputs()) {
			File directory = new File(output).getAbsoluteFile();
			if (outputDirectoryFilter != null) {
				directory = outputDirectoryFilter.apply(directory, basename);
			}
			try {
				final File outputFile = new File(directory, basename);
				outputFile.getParentFile().mkdirs();
				Files.write(Paths.get(outputFile.getAbsolutePath()), content);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
1303415
public function writeCrop($path, $contents) {
        try {
            $this->getCropsDisk()->write($path, $contents);
        } catch(FileExistsException $e) {
            throw new Exception("Croppa: Crop already exists at $path. You probably
                have a misconfiguration. Make sure that the URL to your crop can be
                transformed by the `path` config to your `crop_dir`.");
        }

    }
1236031
public function writeFile($content, $append = true, $addNL = true)
	{
		file_put_contents(
			$this->absolute_path,
			($addNL) ? $content . PHP_EOL : $content,
			($append) ? FILE_APPEND | LOCK_EX: LOCK_EX
		);
	}
327339
public function overwrite($file, $content)
    {
        $written = file_put_contents($file, $content);

        // If $content is not empty
        // but nothing was written to $file
        // throw an exception.
        if ($content and ! $written)
        {
            throw new RuntimeException(
                "Unable to write to {$file}."
            );
        }
    }
82290
public function saveToFile($strFolder, $strFilename = '', $blnSkipDb = false)
    {
        $strFilename = $strFilename ?: $this->buildFilename();

        // create if not exists
        new \Folder($strFolder);

        $this->objPdf->Output(TL_ROOT . '/' . trim($strFolder, '/') . '/' . $strFilename, 'F');

        // save database entity
        if (!$blnSkipDb)
        {
            $objFile = new \File(trim($strFolder, '/') . '/' . $strFilename);
            $objFile->close();
        }
    }