TreeDownX

Название TreeDownX
Имя файла (*.txt) TreeDownX.txt
Описание Осуществляет движение по дереву директорий сверху вниз
Автор Вахмурка (идея Gregory)
Параметры %P%N
Вызываемые плагины win, file, tc, miscplugin, vec
Иконка
Версия 3.0
Дата обновления 13.03.2010
Внешняя программа Xxcopy
local FullPath = x9
local hwnd = win.handle("c=TTOTAL_CMD")
static Quote = esc(?+\"+, ?+\+)
static Slash = "\"
local Path = file.folder(FullPath)
Path = trim(Path, " ", 3)
Path = trim(Path, Quote, 3)
local Result = slice(Path, 3)
local Name = file.nametype(FullPath)
Name = trim(Name, Quote, 3)
FullPath = Path ++ Slash ++ Name

if(file.isfolder(FullPath) && Name) do
	win.sendmessage(hwnd, 0x400+51, 2003, 0)
	quit
endif

if(not file.validpath(Result)) do
	messagebox("ok error", "Unknown drive: " ++ Result, "Invalid path")
	quit
endif

if(not file.isfolder(FullPath)) do				
	if(length(Path) <= 3)
		NextDrive(hwnd)

	Name = file.nametype(Path)
	Path = file.folder(Path)
endif

for(1)
	Result = Down(Path, Name)

	if(Result == -1)
		quit

	if(not Result) do
		if(length(Path) <= 3)
			NextDrive(hwnd)

		Name = file.nametype(Path)
		Path = file.folder(Path)
	else
		tc.cd(hwnd, Result)
		keys {home}
		quit
	endif
endfor

quit
//=============================================
Function Down(Path, Name)

local FullPath = Path ++ ifelse(Name != "", Slash ++ Name ++ Slash, Slash)
Path = PutQuote(Path ++ "\*.*")
FullPath = trim(FullPath, Quote, 3)
local Report = miscplugin.tempfilename()
local Str = Path ++ " /ltree /dl2 /h /e /fo" ++ Report
local ExitCode = file.runwait(0, "путь\xxcopy.exe", Str, "", "hide")
local i

if(ExitCode != 0 && ExitCode != 100) do
	messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeDownX Script")
	quit(-1)
endif

local Temp = file.readall(Report)
Report = line(Temp, 0)

if(Report == 1)
	quit

local v = vec.create(Report)
if(v <= 0) do
	messagebox("ok error", "Vector not created", "VEC plugin error")
	quit(-1)
endif

for(i = 0; i < Report; i++)
	Str = trim(line(Temp, i + 1), "<DIR>", 2)
	v[i] = trim(Str, " ", 2)
endfor

v.sortstring
Temp = v.binsearch(FullPath)

if(Temp == -1 || Temp + 1 == Report) do
	quit
else
	quit(v[Temp + 1])
endif
quit
//=============================================
Function PutQuote(Str)
if(find(Str, " ") != -1) do
	Str = trim(Str, Quote, 3)
	Str = Quote ++ 	Str ++ Quote
endif
quit(Str)
//=============================================
Function NextDrive(hwnd)
*Exec Prompt 1 Last folder in root visited. Go to the next drive?
if(not pproflag(1))
	quit all

win.sendmessage(hwnd, 0x400+51, 2051, 0)
win.sendmessage(hwnd, 0x400+51, 2001, 0)
quit all

Комментарии:

См. описание движения по дереву.


На главную Все о Total Commander PowerPro PowerPro & Total Commander