Check-in [e4d5f7bb08]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:If the /home parameter is not an existing directory, continue looking at the other possibilities.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | develop
Files: files | file ages | folders
SHA1: e4d5f7bb084a2bb4a9f467fc6f09f0edf9ecbe2d
User & Date: tinus 2018-03-22 20:36:03.591
Context
2018-03-23
21:16
Implemented command-line help. check-in: 41b3d45087 user: tinus tags: develop
2018-03-22
20:36
If the /home parameter is not an existing directory, continue looking at the other possibilities. check-in: e4d5f7bb08 user: tinus tags: develop
2018-03-21
21:51
Simplified(?) handling of aggregate exceptions. check-in: d8049380d5 user: tinus tags: develop
Changes
Unified Diff Ignore Whitespace Patch
Changes to ZTUpdater/Program.cs.
96
97
98
99
100
101
102

103
104
105
106
107
108
109
                Console.ForegroundColor = BackupColor;
                return 255;
            }
        }

        private static void ShowHelp()
        {

            throw new NotImplementedException();
        }

        private static Dictionary<TraceLevel, ConsoleColor> _levelColors = new Dictionary<TraceLevel, ConsoleColor>();

        private static Action<string, TraceLevel> WriteLog(TraceLevel minimumLevel)
        {







>







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
                Console.ForegroundColor = BackupColor;
                return 255;
            }
        }

        private static void ShowHelp()
        {
            // TODO
            throw new NotImplementedException();
        }

        private static Dictionary<TraceLevel, ConsoleColor> _levelColors = new Dictionary<TraceLevel, ConsoleColor>();

        private static Action<string, TraceLevel> WriteLog(TraceLevel minimumLevel)
        {
Changes to ZTUpdater/ZTUpdater.cs.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        public string Executable { get; private set; } = Environment.Is64BitOperatingSystem ? "ZTW64.exe" : "ZTW.exe";
        public string CurrentVersion { get; private set; }
        public string LatestVersion { get; private set; }
        public string WhatsNew { get; private set; }

        private string _ZTreeHome;

        public ZTWUpdater() : this(GetZTreeHome())
        {
        }
        public ZTWUpdater(string ztreeHome)
        {
            ZTreeHome = ztreeHome;
        }

        public string ZTreeHome
        {
            get
            {
                return _ZTreeHome;
            }
            set
            {
                _ZTreeHome = value;
                if (_ZTreeHome != null)
                {
                    var Executables = Directory.GetFiles(ZTreeHome, Executable);
                    if (Executables.Length > 0)







|









<
<
|
<







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


38

39
40
41
42
43
44
45
        public string Executable { get; private set; } = Environment.Is64BitOperatingSystem ? "ZTW64.exe" : "ZTW.exe";
        public string CurrentVersion { get; private set; }
        public string LatestVersion { get; private set; }
        public string WhatsNew { get; private set; }

        private string _ZTreeHome;

        public ZTWUpdater() : this(FindZTreeHome())
        {
        }
        public ZTWUpdater(string ztreeHome)
        {
            ZTreeHome = ztreeHome;
        }

        public string ZTreeHome
        {


            get => _ZTreeHome;

            set
            {
                _ZTreeHome = value;
                if (_ZTreeHome != null)
                {
                    var Executables = Directory.GetFiles(ZTreeHome, Executable);
                    if (Executables.Length > 0)
57
58
59
60
61
62
63
64
65
66
67
68
69
70


71



72

73

74
75
76
77
78
79
80
        }

        protected void Log(string message, TraceLevel level = TraceLevel.Verbose)
        {
            OnLog(message, level);
        }

        public static string GetZTreeHome()
        {
            // from command-line arguments
            bool Found = false;
            foreach (var Arg in Environment.GetCommandLineArgs())
            {
                if (Found)


                    return Arg;



                else if (Arg == "/home")

                    Found = true;

            }

            // from the environment
            string ZTHome = Environment.GetEnvironmentVariable("#ZTHome");
            if (Directory.Exists(ZTHome))
                return ZTHome;








|






>
>
|
>
>
>

>

>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
        }

        protected void Log(string message, TraceLevel level = TraceLevel.Verbose)
        {
            OnLog(message, level);
        }

        public static string FindZTreeHome()
        {
            // from command-line arguments
            bool Found = false;
            foreach (var Arg in Environment.GetCommandLineArgs())
            {
                if (Found)
                {
                    if (Directory.Exists(Arg))
                        return Arg;
                    else
                        break;
                }
                else if (Arg == "/home")
                {
                    Found = true;
                }
            }

            // from the environment
            string ZTHome = Environment.GetEnvironmentVariable("#ZTHome");
            if (Directory.Exists(ZTHome))
                return ZTHome;

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
                    {
                        WhatsNew = Utils.HtmlToText(WhatsNew);
                    }
                    catch
                    {
                        // ignore errors, just use the HTML instead
                    }
                    Log($"What’s New in v{LatestVersion}:" + Environment.NewLine + WhatsNew, TraceLevel.Info);
                }

                // extract the download link
                Match = _rexLink.Match(Html);
                if (!Match.Success)
                {
                    Log($"No download link found for version {LatestVersion}!", TraceLevel.Warning);







|







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
                    {
                        WhatsNew = Utils.HtmlToText(WhatsNew);
                    }
                    catch
                    {
                        // ignore errors, just use the HTML instead
                    }
                    Log($"What’s New in v{LatestVersion}:" + Environment.NewLine + WhatsNew + Environment.NewLine, TraceLevel.Info);
                }

                // extract the download link
                Match = _rexLink.Match(Html);
                if (!Match.Success)
                {
                    Log($"No download link found for version {LatestVersion}!", TraceLevel.Warning);