Esempio n. 1
0
        public static async Task <bool> EnsureLatestInstalled(string path)
        {
            string latestInfo =
                DownloadForm.DownloadString("Checking for sampctl update...", "http://api.github.com/repos/Southclaws/sampctl/releases/latest");
            var    mtch    = Regex.Match(latestInfo, "\"tag_name\":\"(?<version>.+?)\",");
            string version = mtch.Groups["version"].Value;

            //If exists and different version, download, else keep.
            if (File.Exists(Path.Combine(path, "sampctl.exe")) == false || (File.Exists(Path.Combine(path, "sampctl.exe")) && await GetCurrentVersion(Path.Combine(path, "sampctl.exe")) != version))
            {
                string arch           = Environment.Is64BitOperatingSystem ? "amd64" : "386";
                string fileToDownload =
                    $@"https://github.com/Southclaws/sampctl/releases/download/{version}/sampctl_{version}_windows_{arch}.tar.gz";
                DownloadForm.DownloadFile("Downloading SampCTL...", fileToDownload, Path.Combine(path, "archive.tar.gz"));
                GeneralFunctions.FastZipUnpack(Path.Combine(path, "archive.tar.gz"), path, "sampctl.exe");
                File.Delete(Path.Combine(path, "archive.tar.gz"));
            }

            return(true);
        }