-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugVer.lua
47 lines (46 loc) · 1.62 KB
/
PlugVer.lua
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
-- PlugVer() - retrive Far plug-ins version string
--
-- Parameters (plg,mod[,fmt])
-- plg - GUID or full path to the plugin DLL
-- mod - 1 or 2 flag of type plug: 1 - GUID, 2 - path to the DLL,
-- fmt - response line format: 0 - Major.Minor.Build.Revision; 1 - Major.Minor.Build.
-- By default, or if the fmt parameter is omitted then Major.Minor.Build.Revision
--
-- Returns:
--
-- Version string of the plugin in to format "Major.Minor.Build [.Revision]" or "nil" if error.
--
-- Notes:
--
-- The plugin must be installed in your copy of Far!
--
-- Usage:
--
-- PlugVer("GUID",1[,0|1}) receiving the plugin version with the specified GUID;
-- PlugVer("Path",2[,0|1}) getting the plugin version with the full path to the DLL
--
-- Examples:
--
-- far.Message(PlugVer("9D4A59D9-AD2D-478C-8F66-7D233CBB788D",1,0),"Version:")
-- far.Message(PlugVer(win.GetEnv("FARHOME").."\\plugins\\imageview\\ImageView.dll",2,1),"Version:")
--
-- Also see demo.lua for more examples.
--
-- History:
--
-- Initial release
-- v1.0, VictorVG, 16.08.2019 22:53:34 +0300
-- Refactoring
-- v1.1, VictorVG, 16.08.2019 22:53:34 +0300
-- Refactoring
-- v1.2, VictorVG, 17.08.2019 06:16:44 +0300
-- History - date fix typo
-- v1.2.0.1, VictorVG, 18.08.2019 12:11:55 +0300
local function PlugVer(plg,mod,fmt)
local Info,PVer,A,P
if mod == 1 then P=far.FindPlugin("PFM_GUID",win.Uuid(plg)) else P=far.FindPlugin("PFM_MODULENAME",plg) end
Info=far.GetPluginInformation(P);
A=Info.GInfo.Version;
if fmt == 1 then PVer=A[1].."."..A[2].."."..A[3] else PVer=A[1].."."..A[2].."."..A[3].."."..A[4] end
return PVer
end