public static function recursiveRemove($path)
    {
        if (is_dir($path)) {
            $files = scandir($path);
            foreach ($files as $file) {
                if ($file != "." && $file != "..") {
                    self::recursiveRemove("$path/$file");
                }
            }
            if (!rmdir($path)) {
                throw new IOException("Cannot rmdir '$path'", 0, null, $path);
            }
        } elseif (file_exists($path)) {
            if (!unlink($path)) {
                throw new IOException("Cannot unlink '$path'", 0, null, $path);
            }
        }
    }