Code: Select all
local F = far.Flags
local ICId, FailId, SuccId = "E186306E-3B0D-48C1-9668-ED7CF64C0E65", win.Uuid"01672689-DED5-4BF6-A6EB-88A0B7EC0D0F", win.Uuid"A41F7DA9-F678-48F5-8159-BF615C4B9EB7"
local Mask="/.+\\.(md5|sfv|sha(1|3|256|512)|wrpl)/i";
local Process, Result, iSucc, iFail = false, nil, 0, 0
Macro{
id="4B2EC566-B05E-4900-BD56-C4A5449E57EB";
area="Shell";
key="CtrlC-C";
description="BAX - Проверка файлов по отмеченным hash-суммам";
flags="Selection"; -- EnableOutput RunAfterFARStart EmptyCommandLine NotEmptyCommandLine NoFilePanels NoFilePPanels NoPluginPanels NoPluginPPanels NoFolders NoPFolders NoFiles NoPFiles Selection PSelection NoSelection NoPSelection EVSelection NoEVSelection NoSendKeysToPlugins
condition=function(key, data) return Plugin.Exist(ICId) end;
action=function(data)
Result, iSucc, iFail = {}, 0, 0
local Src = {}
for i=1, APanel.SelCount do
local fn = panel.GetSelectedPanelItem(nil, 1, i)
if not fn.FileAttributes:match"d" then
fn = fn.FileName
if mf.fmatch(fn, Mask)==1 then
table.insert(Src, fn)
end
end
end
for _, v in ipairs(Src) do
Process = true
Plugin.Command(ICId, v)
end
local sItems = nil
if iSucc > 0 or iFail > 0 then
if iFail > 0 then
local aItems = {}
for _,v in ipairs(Result) do table.insert(aItems, v.text:sub(3)) end
sItems = table.concat(aItems, '\n')
end
table.insert(Result, 1, {text='Проверено ' .. iSucc+iFail .. ' файлов. Соотетствует ' .. iSucc .. '; не соответствует ' .. iFail})
Panel.Select(0, 0)
if iFail > 0 then
table.insert(Result, 2, {text='Список несоответствий:'})
end
else
table.insert(Result, {text='Файлов для проверки не найдено!'})
end
far.Menu({}, Result)
if sItems then Panel.Select(0, 1, 2, sItems) end
end;
}
--------------------------------
Event {
id = "F090A36D-BD02-4399-8C99-2DFC566545D8";
group = "DialogEvent";
description = "BAX - Обработка результатов проверки файла по Хеш";
condition = function(Event, Param)
if Process and Event == F.DE_DLGPROCEND and Param.Msg == F.DN_INITDIALOG then
local Id = (Param.hDlg:send(F.DM_GETDIALOGINFO) or {}).Id
if Id == FailId or Id == SuccId then
Param.Succ = Id == SuccId
return true
end
end
end;
action = function(Event, Param)
if Param.Succ then
iSucc = iSucc + 1
else
iFail = iFail + 1
local n = Param.hDlg:send(F.DM_LISTINFO, 2).ItemsNumber
for i=2,n do
table.insert(Result, {text=Param.hDlg:send(F.DM_LISTGETITEM,2,i).Text})
end
end
Process = false
Param.hDlg:send(F.DM_CLOSE, -2)
end;
}