public static function buildDir($path, $chmod = 0775) {
        deprecated('mkdir($dir, null, true);');
        if (is_dir($path)) {
            return true;
        }
        $dir = DIRECTORY_SEPARATOR;
        foreach(explode(DIRECTORY_SEPARATOR, self::unify_slashes($path, DIRECTORY_SEPARATOR, true)) as $f) {
            if (empty($f)) {
                continue;
            }
            $dir .= $f.DIRECTORY_SEPARATOR;
            if (is_dir($dir)) {
                continue;
            }

            if (is_writable(dirname($dir))) {
                mkdir($dir, $chmod);
            } else {
                return false;
            }
        }
        return true;
    }