clip.save
local hwnd = win.handle("c=TTOTAL_CMD")
static XX = "path\xxcopy.exe"
static Slash = "\"
static Quote = esc(?+\"+, ?+\+)
clip.clear
win.sendmessage(hwnd, 0x400+51, 2029, 0)
wait.for(clip.get)
local Path = clip.get
local Drive = slice(Path, 3)
clip.load
local Name, Result
if(not validpath(Drive)) do
messagebox("ok error", "Unknown drive: " ++ Drive, "Invalid path")
quit
endif
if(length(Path) > 3) do
Name = file.nametype(Path)
Path = file.folder(Path)
else
*Exec Prompt 1 First folder in root visited. Go to the previous drive?
if(not pproflag(1))
quit
win.sendmessage(hwnd, 0x400+51, 2052, 0)
win.sendmessage(hwnd, 0x400+51, 2001, 0)
quit
endif
Result = Up(Path, Name)
if(Result == -1)
quit
if(not Result) do
win.sendmessage(hwnd, 0x400+51, 2002, 0)
keys {home}
quit
endif
Path = Result
Result = Lowest(Path)
tc.cd(hwnd, Result)
keys {home}
quit
//=============================================
Function Up(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 /fo" ++ Report
local ExitCode = file.runwait(0, XX, Str, "", "hide")
if(ExitCode != 0 && ExitCode != 100) do
messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeUpXMouse Script")
quit(-1)
endif
local Temp = file.readall(Report)
Report = line(Temp, 0)
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) do
quit
else
quit(v[Temp - 1])
endif
//=============================================
Function Lowest(Path)
local Param = PutQuote(Path ++ "*.*")
local Report = miscplugin.tempfilename()
local Str = Param ++ " /ltree /h /e /fo" ++ Report
local ExitCode = file.runwait(0, XX, Str, "", "hide")
if(ExitCode != 0 && ExitCode != 100) do
messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeUpXMouse Script")
quit all
endif
local Temp = file.readall(Report)
Report = line(Temp, 0)
if(Report == 1)
quit(Path)
Str = trim(line(Temp, Report), "<DIR>", 2)
Str = trim(Str, " ", 2)
quit(Str)
//=============================================
Function PutQuote(Str)
if(find(Str, " ") != -1) do
Str = trim(Str, Quote, 3)
Str = Quote ++ Str ++ Quote
endif
quit(Str)