コード例 #1
0
        protected override void GetInstalledVersion()
        {
            const string versionRegexString = @"Build: ffmpeg-(\d{4})(\d{2})(\d{2})";
            string       readmePath         = Path.Combine(FFMPEG_PATH, "README.txt");

            if (!File.Exists(readmePath))
            {
                return;
            }

            var   versionRegex     = new Regex(versionRegexString, RegexOptions.IgnoreCase);
            Match versionLineMatch = null;

            using (var stream = new StreamReader(readmePath))
            {
                do
                {
                    string line = stream.ReadLine();
                    versionLineMatch = versionRegex.Match(line);
                } while (!versionLineMatch.Success && !stream.EndOfStream);
            }

            // Corrupt installation? Format change? Either way, proceed with update and hope that fixes it??
            if (!versionLineMatch.Success)
            {
                return;
            }

            string year  = versionLineMatch.Groups[1].Value;
            string month = versionLineMatch.Groups[2].Value;
            string day   = versionLineMatch.Groups[3].Value;

            InstalledVersion = TimestampVersion.Parse($"{year}-{month}-{day}");
        }
コード例 #2
0
        public int CompareTo(TimestampVersion other)
        {
            if (other == null)
            {
                return(1);
            }

            return(CompareTo((IVersion)other));
        }
コード例 #3
0
        protected override void GetAvailableVersion()
        {
            const string webVersionRegex = @"\d{4}-\w{3}-\d{2}";

            try
            {
                AvailableVersion = TimestampVersion.FromWebResource(VersionUrl, webVersionRegex);
            }
            catch (System.Net.WebException x)
            {
                throw new UpdaterException(x.Message, x);
            }
            catch (FormatException x)
            {
                throw new UpdaterException("Failed to parse available version. The resource may have changed or moved.", x);
            }
        }