protected function processOutputFilepath($outputPath, $conflictMode, $dirMode)
    {
        $outputIsDirectory = $this->pathIsDirectory($outputPath);

        //check for pre-existing file and handle based on conflict mode
        if (file_exists($outputPath)) {
            if ($conflictMode === self::ONCONFLICT_EXCEPTION) {
                throw new Exception\FileAlreadyExistsException(sprintf("File %s already exists.", $outputPath));
            }

            if ($conflictMode === self::ONCONFLICT_DELETE) {
                if ($outputIsDirectory) {
                    $this->removeDirectory($outputPath);
                } else {
                    @unlink($outputPath);
                }
            }

            if ($conflictMode === self::ONCONFLICT_INCREMENT) {
                $outputPath = $this->incrementConflictingPath($outputPath);
            }
        }

        //check for necessary containing directory creation, handle based on directory mode
        $outputDirectory = dirname($outputPath);

        if (!file_exists($outputDirectory)) {
            if ($dirMode === self::ONDIR_EXCEPTION) {
                throw new Exception\InvalidModeException("The Transcoder is not permitted to create new directories if needed.");
            }

            //try creating the necessary containing directories recursively
            if (!mkdir($outputDirectory, $this->getDirectoryCreationMode(), true)) {
                throw new Exception\FilePermissionException("The required containing directories could not be created.");
            }

            $this->dispatcher->dispatch(TranscodeEvents::DIR_CREATED, new FileEvent($outputDirectory));
        }

        //check for write permissions
        if (!is_writable($outputDirectory)) {
            throw new Exception\FilePermissionException(sprintf("Cannot transcode because the directory %s is not writable.", $outputDirectory));
        }

        //if the output is a directory, make sure the actual required directory is created
        if ($outputIsDirectory) {
            if (!mkdir($outputPath, $this->getDirectoryCreationMode())) {
                throw new Exception\FilePermissionException(sprintf("Could not properly create the required output directory %s.", $outputPath));
            }

            $this->dispatcher->dispatch(TranscodeEvents::DIR_CREATED, new FileEvent($outputDirectory));
        }

        return $outputPath;
    }
protected function processOutputFilepath($outputPath, $conflictMode, $dirMode)
    {
        $outputIsDirectory = $this->pathIsDirectory($outputPath);

        //check for pre-existing file and handle based on conflict mode
        if (file_exists($outputPath)) {
            if ($conflictMode === self::ONCONFLICT_EXCEPTION) {
                throw new Exception\FileAlreadyExistsException(sprintf("File %s already exists.", $outputPath));
            }

            if ($conflictMode === self::ONCONFLICT_DELETE) {
                if ($outputIsDirectory) {
                    $this->removeDirectory($outputPath);
                } else {
                    @unlink($outputPath);
                }
            }

            if ($conflictMode === self::ONCONFLICT_INCREMENT) {
                $outputPath = $this->incrementConflictingPath($outputPath);
            }
        }

        //check for necessary containing directory creation, handle based on directory mode
        $outputDirectory = dirname($outputPath);

        if (!file_exists($outputDirectory)) {
            if ($dirMode === self::ONDIR_EXCEPTION) {
                throw new Exception\InvalidModeException("The Transcoder is not permitted to create new directories if needed.");
            }

            //try creating the necessary containing directories recursively
            if (!mkdir($outputDirectory, $this->getDirectoryCreationMode(), true)) {
                throw new Exception\FilePermissionException("The required containing directories could not be created.");
            }

            $this->dispatcher->dispatch(TranscodeEvents::DIR_CREATED, new FileEvent($outputDirectory));
        }

        //check for write permissions
        if (!is_writable($outputDirectory)) {
            throw new Exception\FilePermissionException(sprintf("Cannot transcode because the directory %s is not writable.", $outputDirectory));
        }

        //if the output is a directory, make sure the actual required directory is created
        if ($outputIsDirectory) {
            if (!mkdir($outputPath, $this->getDirectoryCreationMode())) {
                throw new Exception\FilePermissionException(sprintf("Could not properly create the required output directory %s.", $outputPath));
            }

            $this->dispatcher->dispatch(TranscodeEvents::DIR_CREATED, new FileEvent($outputDirectory));
        }

        return $outputPath;
    }
protected function processOutputFilepath ( $ outputPath , $ conflictMode , $ dirMode ) { $ outputIsDirectory = $ this -> pathIsDirectory ( $ outputPath ) ; //check for pre-existing file and handle based on conflict mode if ( file_exists ( $ outputPath ) ) { if ( $ conflictMode === self :: ONCONFLICT_EXCEPTION ) { throw new Exception \ FileAlreadyExistsException ( sprintf ( "File %s already exists." , $ outputPath ) ) ; } if ( $ conflictMode === self :: ONCONFLICT_DELETE ) { if ( $ outputIsDirectory ) { $ this -> removeDirectory ( $ outputPath ) ; } else { @ unlink ( $ outputPath ) ; } } if ( $ conflictMode === self :: ONCONFLICT_INCREMENT ) { $ outputPath = $ this -> incrementConflictingPath ( $ outputPath ) ; } } //check for necessary containing directory creation, handle based on directory mode $ outputDirectory = dirname ( $ outputPath ) ; if ( ! file_exists ( $ outputDirectory ) ) { if ( $ dirMode === self :: ONDIR_EXCEPTION ) { throw new Exception \ InvalidModeException ( "The Transcoder is not permitted to create new directories if needed." ) ; } //try creating the necessary containing directories recursively if ( ! mkdir ( $ outputDirectory , $ this -> getDirectoryCreationMode ( ) , true ) ) { throw new Exception \ FilePermissionException ( "The required containing directories could not be created." ) ; } $ this -> dispatcher -> dispatch ( TranscodeEvents :: DIR_CREATED , new FileEvent ( $ outputDirectory ) ) ; } //check for write permissions if ( ! is_writable ( $ outputDirectory ) ) { throw new Exception \ FilePermissionException ( sprintf ( "Cannot transcode because the directory %s is not writable." , $ outputDirectory ) ) ; } //if the output is a directory, make sure the actual required directory is created if ( $ outputIsDirectory ) { if ( ! mkdir ( $ outputPath , $ this -> getDirectoryCreationMode ( ) ) ) { throw new Exception \ FilePermissionException ( sprintf ( "Could not properly create the required output directory %s." , $ outputPath ) ) ; } $ this -> dispatcher -> dispatch ( TranscodeEvents :: DIR_CREATED , new FileEvent ( $ outputDirectory ) ) ; } return $ outputPath ; }
Scan an output path to make sure there are no conflicts.  Handle conflicts according to mode.  Check to make sure final path is actually writable.
Returns the final output path, which may have been altered depending on the mode.

@param  string $outputPath
@param  string $conflictMode
@param  string $dirMode
@return string
Scan an output path to make sure there are no conflicts . Handle conflicts according to mode . Check to make sure final path is actually writable . Returns the final output path which may have been altered depending on the mode .