app\models\Beatmapset::scanBMForBG PHP Method

scanBMForBG() public method

todo: maybe move this somewhere else (copypasta from old implementation)
public scanBMForBG ( $beatmapFilename )
    public function scanBMForBG($beatmapFilename)
    {
        $content = file_get_contents($beatmapFilename);
        if (!$content) {
            return false;
        }
        $matching = false;
        $imageFilename = '';
        $lines = explode("\n", $content);
        foreach ($lines as $line) {
            $line = trim($line);
            if ($matching) {
                $parts = explode(',', $line);
                if (count($parts) > 2 && $parts[0] === '0') {
                    $imageFilename = str_replace('"', '', $parts[2]);
                    break;
                }
            }
            if ($line === '[Events]') {
                $matching = true;
            }
            if ($line === '[HitObjects]') {
                break;
            }
        }
        // older beatmaps may not have sanitized paths
        $imageFilename = str_replace('\\', '/', $imageFilename);
        return $imageFilename;
    }