Write down the currently loaded Tar Gzip Archive.
@access		public
@param		string		$fileName 		Name of Tar Gzip Archive to save
@return		bool
768253
public function save( $fileName = false )
	{
		if( !$fileName )
		{
			if( !$this->fileName )
				throw new Exception( "No TGZ file name for saving given." );
			$fileName = $this->fileName;
		}
		$this->generateTar();												// Encode processed files into TAR file format
		$f = new FS_File_Arc_Gzip( $fileName );
		$f->writeString( $this->content);
		return true;
	}
605837
public function open($filename)
    {
        $this->filename = $filename;
        return $this->zipArchive->open($filename, ZIPARCHIVE::CREATE);
    }
856351
private function decompressFile($fileName, $outputFilePath)
    {
        if (strpos($fileName, '.tar.gz') !== false) {
            $tmpDir = tempnam(sys_get_temp_dir(), 'MaxMind_');
            unlink($tmpDir);
            mkdir($tmpDir);

            $p = new \PharData($fileName);
            $p->decompress();

            $tarFileName = str_replace('.gz', '', $fileName);
            $phar = new \PharData($tarFileName);
            $phar->extractTo($tmpDir);
            unlink($tarFileName);

            $files = glob($tmpDir.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'*.mmdb');
            if (count($files)) {
                @rename($files[0], $outputFilePath);
            }

            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
                \RecursiveIteratorIterator::CHILD_FIRST
            );
            foreach ($files as $fileinfo) {
                $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
                $todo($fileinfo->getRealPath());
            }
            rmdir($tmpDir);
        } else {
            $gz = gzopen($fileName, 'rb');
            $outputFile = fopen($outputFilePath, 'wb');
            while (!gzeof($gz)) {
                fwrite($outputFile, gzread($gz, 4096));
            }
            fclose($outputFile);
            gzclose($gz);
        }

        return is_readable($outputFilePath);
    }
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);
		}
	}
237369
protected function dumpFile(string $filename)
    {

        if (strlen($filename) > 0 && file_exists($filename) && is_file($filename)) {
            echo file_get_contents($filename);
            return true;
        }

        return false;
    }
238189
public function isEncoded( $fileName )
	{
		if( file_exists( $fileName ) )
		{
			$fp	= fopen( $fileName, "r" );
			$code	= fgets( $fp, strlen( $this->outcodePrefix ) );
			if( $code == $this->outcodePrefix )
				return TRUE;
		}
		return FALSE;
	}
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;
    }
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
118673
function isWriteable( $filename = false )
    {
        if ( !$filename )
            $filename = $this->FileName;
        return $this->doIsWriteable( $filename );
    }
969568
private function readGzipTar( $fileName )
	{
		$f = new FS_File_Arc_Gzip( $fileName );
		$this->content = $f->readString();
		$this->parseTar();																			// Parse the TAR file
		return true;
	}
506673
public static function canOpenArchive($fileName)
    {
        self::checkRequirements();

        $type = self::detectArchiveType($fileName);
        if ($type !== false && self::canOpenType($type)) {
            return true;
        }

        return false;
    }
314784
public function save(string $filename, bool $force_download = false)
    {
        return $this->getWriter()->save($filename, $force_download = false);
    }
623671
public function save($filename)
    {
        $type = pathinfo($filename, PATHINFO_EXTENSION);
        $type = ($type === 'jpg') ? 'jpeg' : $type;
        $type = (in_array($type, $this->imageTypes)) ? $type : 'png';

        header('Content-type: image/' . $type);

        $imageFunc = 'image' . $type;
        $imageFunc($this->image, $filename);

        $this->destroy($this->image);

        return $this;
    }
1085389
public function save( $fileName )
	{
		$svg	= $this->encapsulate( $this->content );
		$doc	= new DOMDocument();
		$doc->preserveWhiteSpace = false; 
		$doc->formatOutput = true;
		$doc->loadXml( $svg );
		$svg	= $doc->saveXml();
		return FS_File_Writer::save( $fileName, $svg );
	}
786142
public function download($filename = 'backup.zip')
	{
		if ( ! preg_match('|.+?\.zip$|', $filename))
		{
			$filename .= '.zip';
		}

		$this->factory->helpers->load('download');
		$get_zip = $this->get_zip();
		$zip_content =& $get_zip;

		force_download($filename, $zip_content);
	}
366836
public function read($filename = false)
		{
			if (true === $this->_enabled && !empty($filename)) {
				$index	= $this->_zip->locateName($filename, \ZipArchive::FL_NODIR);

				if ($index) {
					return $this->_zip->getFromIndex((int)$index);
				}
			}

			return false;
		}
247949
public function download($filename = '')
    {
        $filename = $this->formatFilename($filename);
        if ($this->content) {
            $this->printHeader();
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            echo $this->content;
        } elseif ($this->path) {
            $fsize = filesize($this->path);
            $this->printHeader($fsize);
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            readfile($this->path);
        }
    }