load_vtm.anubis
3.13 KB
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
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 29/03/2018
* Time: 22:35
* © Calexium
*/
transmit view_table_manager_types.anubis
define String modules_directory = find_and_replace(my_anubis_directory, "\\", "/") + "/modules/".
public define Maybe(VTM)
load_plugin
(
String file_name
)
=
if (LoadAdm(VTM))load_adm(file_name) is
{
file_not_found then print("File '"+file_name+"' not found.\n\n");failure,
read_error then print("Error reading file '"+file_name+"'.\n\n");failure,
timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure,
file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure,
bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+
" version ("+found+") as primary module ("+expected+").\n\n");failure,
wrong_type(expected,found) then print("Secondary module '"+file_name+"' has type:\n"+
found+" while primary module expected:\n"+
expected+"\n\n");failure,
ok(vtm_plugin) then println("vtm plugin "+vtm_plugin.db_version+" loaded "); success(vtm_plugin)
}.
define Maybe(VTM)
load_vtm
(
List(String) left,
DB_Version vtm_version
)=
if left is
{
[] then failure,
[file_name . t] then
if load_plugin(modules_directory+file_name) is
{
failure then load_vtm(t, vtm_version),
success(_vtm) then
if compare_db_version(_vtm.db_version, vtm_version) is
{
less then load_vtm(t, vtm_version),
more then failure,
equal then success(_vtm),
equal_but_sign then success(_vtm)
}
}
}
.
define Maybe(VTM)
load_latest_vtm
(
List(String) left,
VTM _current_vtm
)=
if left is
{
[] then
since _current_vtm is vtm(_version, _, _, _),
if _version.version.numeric = 0 & _version.db_hash = "" then
failure
else
success(_current_vtm),
[file_name . t] then
if load_plugin(modules_directory+file_name) is
{
failure then load_latest_vtm(t, _current_vtm),
success(_vtm) then
if compare_db_version( _vtm.db_version, _current_vtm.db_version) is
{
less then load_latest_vtm(t, _current_vtm),
more then load_latest_vtm(t, _vtm),
equal then load_latest_vtm(t, _current_vtm),
equal_but_sign then load_latest_vtm(t, _current_vtm)
}
}
}
.
public define Maybe(VTM)
load_vtm
(
DB_Version vtm_version
)
=
with files = directory_list(modules_directory, "vtm_v*.adm"),
load_vtm(files, vtm_version)
.
public define Maybe(VTM)
load_latest_vtm
=
with files = directory_list(modules_directory, "vtm_v*.adm"),
load_latest_vtm(files, blank_vtm)
.