src/Knp/Snappy/AbstractGenerator.php
protected function prepareOutput($filename, $overwrite)
    {
        $directory = dirname($filename);

        if ($this->fileExists($filename)) {
            if (!$this->isFile($filename)) {
                throw new \InvalidArgumentException(sprintf(
                    'The output file \'%s\' already exists and it is a %s.',
                    $filename, $this->isDir($filename) ? 'directory' : 'link'
                ));
            } elseif (false === $overwrite) {
                throw new Exceptions\FileAlreadyExistsException(sprintf(
                    'The output file \'%s\' already exists.',
                    $filename
                ));
            } elseif (!$this->unlink($filename)) {
                throw new \RuntimeException(sprintf(
                    'Could not delete already existing output file \'%s\'.',
                    $filename
                ));
            }
        } elseif (!$this->isDir($directory) && !$this->mkdir($directory)) {
            throw new \RuntimeException(sprintf(
                'The output file\'s directory \'%s\' could not be created.',
                $directory
            ));
        }
    }
protected function prepareOutput($filename, $overwrite)
    {
        $directory = dirname($filename);

        if ($this->fileExists($filename)) {
            if (!$this->isFile($filename)) {
                throw new \InvalidArgumentException(sprintf(
                    'The output file \'%s\' already exists and it is a %s.',
                    $filename, $this->isDir($filename) ? 'directory' : 'link'
                ));
            } elseif (false === $overwrite) {
                throw new Exceptions\FileAlreadyExistsException(sprintf(
                    'The output file \'%s\' already exists.',
                    $filename
                ));
            } elseif (!$this->unlink($filename)) {
                throw new \RuntimeException(sprintf(
                    'Could not delete already existing output file \'%s\'.',
                    $filename
                ));
            }
        } elseif (!$this->isDir($directory) && !$this->mkdir($directory)) {
            throw new \RuntimeException(sprintf(
                'The output file\'s directory \'%s\' could not be created.',
                $directory
            ));
        }
    }
protected function prepareOutput ( $ filename , $ overwrite ) { $ directory = dirname ( $ filename ) ; if ( $ this -> fileExists ( $ filename ) ) { if ( ! $ this -> isFile ( $ filename ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The output file \'%s\' already exists and it is a %s.' , $ filename , $ this -> isDir ( $ filename ) ? 'directory' : 'link' ) ) ; } elseif ( false === $ overwrite ) { throw new Exceptions \ FileAlreadyExistsException ( sprintf ( 'The output file \'%s\' already exists.' , $ filename ) ) ; } elseif ( ! $ this -> unlink ( $ filename ) ) { throw new \ RuntimeException ( sprintf ( 'Could not delete already existing output file \'%s\'.' , $ filename ) ) ; } } elseif ( ! $ this -> isDir ( $ directory ) && ! $ this -> mkdir ( $ directory ) ) { throw new \ RuntimeException ( sprintf ( 'The output file\'s directory \'%s\' could not be created.' , $ directory ) ) ; } }
Prepares the specified output.

@param string $filename  The output filename
@param bool   $overwrite Whether to overwrite the file if it already
exist

@throws Exception\FileAlreadyExistsException
@throws \RuntimeException
@throws \InvalidArgumentException
Prepares the specified output .