protected function removeDirectory($path)
    {
        foreach (scandir($path) as $item) {
            if (!in_array($item, array('.','..'))) {
                @unlink($path.DIRECTORY_SEPARATOR.$item);
                $this->dispatcher->dispatch(TranscodeEvents::DIR_REMOVED, new FileEvent($outputPath));
            }
        }

        if (!rmdir($path)) {
            throw new Exception\FilePermissionException(sprintf("Could not remove directory %s", $path));
        }
    }