public static function recursiveMkdir(string $dir, int $loops = 0) {
        if ($loops > 20)
            throw new UtilException('No more than 20 directories in a row');
        if(!file_exists($newdir = dirname($dir)))
            self::recursiveMkdir($newdir);
        @mkdir($dir);
        @chmod($dir, 0777);
    }