-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
save.hac
148 lines (130 loc) · 4.72 KB
/
save.hac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
49
50
51
52
53
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
--#!/usr/bin/env hac
-- Local backup Ada shell script for the HAC project.
--
-- This script works both with HAC (command: hac save.adb)
-- and a full Ada compiler like GNAT, and that on different
-- Operating Systems: Linux and Windows at least.
--
-- A "shebang" for Unix/Linux, such as "#!/usr/bin/env hac" can be
-- added on the top line of this file.
-- HAC will ignore it, but GNAT won't like it (that's normal).
--
-- The extension for the main procedure is a free choice.
-- We choose ".hac" so we can associate the ".hac" files by
-- default with hac.exe on Windows, for Explorer *and* command-line!
-- Explorer: double-click / hit Return on "save.hac".
-- Cmd / PowerShell: type "save.hac" and hit Return.
with HAT;
procedure Save is
use HAT;
function Nice_Date (with_intraday : Boolean) return VString is
t1 : constant Time := Clock;
day_secs, day_mins : Integer;
just_day : VString;
--
function Two_Digits (x : Integer) return VString is
begin
if x < 10 then
return "0" & Image (x);
else
return Image (x);
end if;
end Two_Digits;
--
begin
day_secs := Integer (Seconds (t1));
day_mins := day_secs / 60;
just_day := +"" & -- VString concatenation
Year (t1) & '-' &
Two_Digits (Month (t1)) & '-' &
Two_Digits (Day (t1));
if with_intraday then
return just_day & "--" &
Two_Digits (day_mins / 60) & '-' &
Two_Digits (day_mins mod 60) & '-' &
Two_Digits (day_secs mod 60);
else
return just_day;
end if;
end Nice_Date;
root, demos, examples, files, tests : VString;
zip_res : Integer;
sep : constant Character := Directory_Separator;
begin
Put_Line ("Save date: " & Nice_Date (True));
Put_Line ("Current directory: " & Current_Directory);
Put_Line ("-----");
root := Tail_After_Match (Current_Directory, sep);
Set_Directory ("..");
demos := root & "/demo/data_exchange/*.ad* " &
root & "/demo/data_exchange_simple/*.ad* " &
root & "/demo/*.gpr " &
root & "/demo/*.prj ";
examples := root & "/exm/*.ad* " &
root & "/exm/*.gpr " & root & "/exm/*.prj " &
root & "/exm/e.cmd " &
root & "/exm/not_working/*.ad* " &
root & "/exm/pdf/*.ad* " &
root & "/exm/tasking/*.ad* " &
--
root & "/exm/aoc/2020/aoc*.ad* " &
root & "/exm/aoc/2020/aoc*.txt " &
root & "/exm/aoc/2020/aoc*.gpr " &
root & "/exm/aoc/2020/aoc*.prj " &
--
root & "/exm/aoc/2021/aoc*.ad* " &
root & "/exm/aoc/2021/aoc*.txt " &
root & "/exm/aoc/2021/aoc*.gpr " &
--
root & "/exm/aoc/2022/aoc*.ad* " &
root & "/exm/aoc/2022/aoc*.txt " &
root & "/exm/aoc/2022/aoc*.gpr " &
--
root & "/exm/aoc/2023/aoc*.ad* " &
root & "/exm/aoc/2023/aoc*.txt " &
root & "/exm/aoc/2023/aoc*.gpr " &
root & "/exm/mathe_kal/2022/m*.ad* " &
root & "/exm/mathe_kal/2022/m*.gpr ";
tests := root & "/test/*.ad* " &
root & "/test/*.gpr " & root & "/test/*.prj " &
root & "/test/t.cmd " &
root & "/test/tf.cmd " &
root & "/test/*.aru " &
root & "/test/future/*.ad* ";
files := root & "/src/*.ad* " &
root & "/src/apps/*.ad* " &
root & "/src/compile/*.ad* " &
root & "/src/compile/emit/*.ad* " &
root & "/src/execute/*.ad* " &
root & "/src/manage/*.ad* " &
root & "/*.gpr " &
root & "/*.prj " &
root & "/*.hac " &
root & "/build.cmd " &
root & "/fast.cmd " &
root & "/small.cmd " &
root & "/*.txt " &
root & "/doc/hac*.txt " &
root & "/doc/hac*.xls " &
root & "/doc/hac*.pdf " &
root & "/debug.pra " &
root & "/obj/hac_icon* " &
root & "/obj/debug/create_dir.txt " &
root & "/obj/fast/create_dir.txt ";
files := files & ' ' & demos & ' ' & examples & ' ' & tests;
-- The ZipAda command-line tool can be built or downloaded
-- from the project Zip-Ada @
-- https://unzip-ada.sourceforge.io/ ,
-- https://github.com/zertovitch/zip-ada
-- or from ALIRE (Ada LIbrary REpository) @ https://alire.ada.dev/
--
Shell_Execute ("zipada -ep2 " & root & sep & root & '-' & Nice_Date (True) & "- " & files, zip_res);
if zip_res = 0 then
Put_Line ("Zip archive creation successful");
else
Put_Line ("Zip archive creation failed");
end if;
Set_Directory (root);
Put ("Press Return ");
Skip_Line;
end Save;