Saves the cookies to a file.

@param string $filename File to save
@throws \RuntimeException if the file cannot be found or created
489945
public function save($filename)
    {
        $json = [];
        foreach ($this as $cookie) {
            /** @var SetCookie $cookie */
            if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
                $json[] = $cookie->toArray();
            }
        }

        $jsonStr = \GuzzleHttp\json_encode($json);
        if (false === file_put_contents($filename, $jsonStr)) {
            throw new \RuntimeException("Unable to save file {$filename}");
        }
    }
1271841
public function setLogFile( $fileName )
	{
		$this->logFile = $fileName;
		if( !file_exists( dirname( $fileName ) ) )
			mkDir( dirname( $fileName ), 0700, TRUE );
	}
628971
static private function ensureDirExists($filename) {
		$logdir= dirname($filename);
		if(!file_exists($logdir)) {
			mkdir($logdir, 0775, true);
			chmod($logdir, 0775);
		}
		
		// check if writeable and if not, write a hint in Objectcache
		$cache = \ObjectCache::getInstance(CACHE_DB);
		$cache->delete('DIQA.Util.logFileNotWriteable');
		@touch($filename);
		if (!is_writeable($filename)) {
			global $wgDIQAUtilLogDir;
			$cache->set('DIQA.Util.logFileNotWriteable', $wgDIQAUtilLogDir);
		}
	}
116908
public function save(array $data, string $filename)
    {
        if (!is_writeable(dirname($filename))) {
            throw new NeuralyzerConfigurationException(dirname($filename) . ' is not writable.');
        }

        file_put_contents($filename, Yaml::dump($data, 4));
    }
1085816
public function _savePageSource($filename)
    {
        if (!isset($this->webDriver)) {
            $this->debug('WebDriver::_savePageSource method has been called when webDriver is not set');
            return;
        }
        try {
            file_put_contents($filename, $this->webDriver->getPageSource());
        } catch (\Exception $e) {
            $this->debug('Unable to retrieve source page from Selenium : ' . $e->getMessage());
        }
    }
613524
function save(string $filename=null): bool
  {
    if (!empty($filename)) $this->filename = $filename;

    return ( file_put_contents($this->filename, json_encode($this->confValues,JSON_PRETTY_PRINT))!==false );
  }
840412
final public function saveImage($filename)
	{
		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		if (! is_string($extension)) {
			$extension = image_type_to_extension($this->_image_type);
			$filename .= ".{$extension}";
		}

		switch(strtolower($extension))
		{
			case 'jpeg':
			case 'jpg':
				return $this->imageJPEG($filename);
				break;

			case 'png':
				return $this->imagePNG($filename);
				break;

			case 'gif':
				return $this->imageGIF($filename);

			default:
				trigger_error('Invalid extension or not an image', E_USER_WARNING);
				return false;
		}
	}
1028445
public function save($filename, $content)
    {
        $this->logs[] = $content;
        $this->storage->save($filename, $content);

        return $this;
    }
331191
public static function putContents($filename, $contents)
    {
        $result = file_put_contents($filename, $contents, \LOCK_EX | \LOCK_NB);
        if ($result === false) {
            throw new \RuntimeException("Cannot write the file: " . $filename);
        }
    }
251340
public function setFileName( $fileName ){
		$this->fileName	= $fileName;
		$this->sheet	= self::load( $fileName );
	}
933424
private function saveContent($file, $content)
    {
        if (file_put_contents($file, $content, LOCK_EX) === false) {
            throw new RuntimeException('Plugin Manager is not able to save ' . $file . '.'); // @codeCoverageIgnore
        }
    }
192437
public function saveToFile($FileName = null)
    {
        if (! is_null($FileName)) {
            $this->FileName = $FileName;
        }

        if (($this->_openSHPFile(true)) && ($this->_openSHXFile(true)) && ($this->_createDBFFile())) {
            $this->_saveHeaders();
            $this->_saveRecords();
            $this->_closeSHPFile();
            $this->_closeSHXFile();
            $this->_closeDBFFile();
        } else {
            return false;
        }
    }
988703
public function toFile($filename, ObjectConfigInterface $config)
    {
        $pathinfo = pathinfo($filename);

        if (!isset($pathinfo['extension']))
        {
            throw new \RuntimeException(sprintf(
                'Filename "%s" is missing an extension and cannot be auto-detected', $filename
            ));
        }

        $this->createFormat($pathinfo['extension'])->toFile($filename, $config);
        return $this;
    }
287845
public function write($message)
    {
        if (! is_null($this->fileHandle)) {
            if (fwrite($this->fileHandle, $message) === false) {
                throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
            }
        }
    }
787555
public static function save(string $filename, string $data): bool
    {
        return \file_put_contents($filename, $data) !== false;
    }
969891
public function setFilename($filename)
    {
        $this->throwExceptionIfProtected();

        $pathInfo = UnicodeFunctions::pathinfo($filename);
        $extension = (isset($pathInfo['extension']) ? '.' . strtolower($pathInfo['extension']) : '');
        $this->filename = $pathInfo['filename'] . $extension;
        $this->mediaType = Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
    }
253862
public function exportToFile(string $fileName, string $password = NULL) {
        $status = openssl_pkcs12_export_to_file($this->getCertificate(), $fileName, $this->getPrivateKey(), $password, $this->getOptions());
        if(!$status) {
            throw new RuntimeException(OpenSSL::getLastError());
        }
    }