local F = far.Flags
local ArcLiteGuid, MultiArcGuid = '65642111-AA69-4B84-B4B8-9249579EC4FA', -- ArcLite
'C5508DDB-5175-4736-9A10-C8F6EED7B32F' -- MultiArc
local BAX_GetMsg = require"BAX.GetMsg"
local function GetMsgEx(tag)
return BAX_GetMsg([[%FarHome%\far*.lng]], tag)
end
local function Action(aFiles, HF, cmd)
local function RemDir(_, fullname) -- удалить файл или каталог со всем содержимым
if win.GetFileAttr(fullname):find("d") then -- каталог?
far.RecursiveSearch(fullname,"*",RemDir) -- почистим его
win.RemoveDir(fullname) -- и удалим
else -- файл
win.DeleteFile(fullname) -- удалим
end
end
local TmpDir = far.MkTemp('Evl')
local function _Action()
local function Expand_Exclamation(s, v)
return
s:gsub('!!', '\1'):gsub('!%.!', mf.fsplit(v, 12)):gsub('!%\\', TmpDir..'\\'):gsub('!', mf.fsplit(v, 4)):gsub('\1','!')
end
win.CreateDir(TmpDir, 't')
if next(aFiles) then
if not Plugin.SyncCall(ArcLiteGuid, 'e', '-out:'..TmpDir..'\\', '"'..HF..'"', unpack(aFiles)) then
far.Message('Неудача распаковки архива '..HF..'\nПапка назначения:\n'..TmpDir, 'ArchFileProc', nil, 'w')
return
end
for _,v in ipairs(aFiles) do
if not win.SetCurrentDir(TmpDir) then
far.Message('Нет каталога '..TmpDir)
break
end
local SavePath = {panel.GetPanelDirectory(nil, 1), APanel.Current}
pcall(function()
panel.SetPanelDirectory(nil,1,{Name=TmpDir});
panel.SetCmdLine(nil, Expand_Exclamation(cmd, v));
Keys"Enter" end)
panel.SetPanelDirectory(nil,1,SavePath[1])
Panel.SetPos(0, SavePath[2])
end -- for _,v in ipairs(aFiles) do
end -- if next(aFiles)
end -- _Action
--Far.DisableHistory(1)
local CurDir = win.GetCurrentDir()
pcall(_Action)
win.SetCurrentDir(CurDir)
far.Show"Сделано!" --Так циклится
RemDir(nil, TmpDir)
panel.RedrawPanel(nil, 0)
panel.RedrawPanel(nil, 1)
far.AdvControl(F.ACTL_REDRAWALL)
Panel.Select(0, 0)
end -- Action(HF)
------------------------------------------------------
Macro{
id="80BC783F-8EFB-4182-BE18-8A6DA8CF9A7A";
area="Shell";
key="CtrlG";
description="Выполнение команды внутри архиа (аналогично стандартному CtrlG)";
flags="";
condition=function(key, data)
if APanel.Plugin then
local og = win.Uuid(panel.GetPanelInfo(nil, 1).OwnerGuid):upper()
return (og == ArcLiteGuid or og == MultiArcGuid )
end
end; -- condition
action=function(data)
local aFiles={}
local cmd = far.InputBox('044EF83E-8146-41B2-97F0-404C2F4C7B69', GetMsgEx('MAskApplyCommandTitle'), GetMsgEx('MAskApplyCommand'), -- Id, Title, Prompt
"ApplyCmd", nil, nil, 'ApplyCmd', -- HistoryName, SrcText, DestLen, HelpTopic,
bor(F.FIB_NOAMPERSAND, F.FIB_EXPANDENV, F.FIB_BUTTONS) )
if cmd then
local SubDir = APanel.Path
if SubDir:sub(1,1) == '\\' then SubDir = SubDir:sub(2) end
if SubDir ~= '' and SubDir:sub(-1) ~= '\\' then SubDir = SubDir .. '\\' end
if APanel.SelCount > 0 then
for i=1,APanel.SelCount do
aFiles[#aFiles+1] = SubDir .. panel.GetSelectedPanelItem(nil, 1, i).FileName
end
else
aFiles[1] = SubDir .. panel.GetCurrentPanelItem(nil, 1).FileName
end
Action(aFiles, APanel.HostFile, cmd)
end
end; -- action
}