don't know if this can help but here is one way of examining recursively a ftp folder (using linked list).
Code: Select all
;============================================
EnableExplicit
#FTP_TRANSFER_ASCII = 1
#FTP_TRANSFER_BINARY = 2
#INTERNET_SERVICE_FTP = 1
#INTERNET_OPEN_TYPE_DIRECT = 1
Import "shlwapi.lib"
StrFormatByteSize64A(Size.q, *BufStr, BufSize.l)
EndImport
Procedure.s StrByteSize(nBytes.q)
Protected string.s{64}
If StrFormatByteSize64A(nBytes, @string, 64)
ProcedureReturn PeekS(@string, -1, #PB_Ascii)
EndIf
EndProcedure
;============================================
Structure FILESIZE
High.l
Low.l
EndStructure
Structure WIN32_FIND_DATA_2
dwFileAttributes.l
ftCreationTime.FILETIME
ftLastAccessTime.FILETIME
ftLastWriteTime.FILETIME
nFileSizeLow.l
nFileSizeHigh.l
dwReserved0.l
dwReserved1.l
cFileName.s{260} ; replaced by fixed string
cAlternate.s{14} ; replaced by fixed string
dummy.w
EndStructure
Macro FtpOpen(Proxy = "", ProxyBypass = "")
InternetOpen_("FTP", #INTERNET_OPEN_TYPE_DIRECT, Proxy, ProxyBypass, 0)
EndMacro
Macro FtpClose(hInternet)
InternetCloseHandle_(hInternet)
EndMacro
Macro FtpConnect(hInternet, Host, User, Pwd, Port = 21)
InternetConnect_(hInternet, Host, Port, User, Pwd, #INTERNET_SERVICE_FTP, 0, 0)
EndMacro
Macro FtpDisconnect(hConnect)
InternetCloseHandle_(hConnect)
EndMacro
;============================================
Procedure.l FtpListAll(hConnect.l, folder.s = "/", depth.l = 0)
Protected hFind.l, Size.q, NewList find.WIN32_FIND_DATA_2()
If FtpSetCurrentDirectory_(hConnect, folder) And AddElement(find())
hFind = FtpFindFirstFile_(hConnect, 0, find(), 0, 0)
If hFind
While AddElement(find()) And InternetFindNextFile_(hFind, find())
; Delay(1)
Wend
InternetCloseHandle_(hFind)
DeleteElement(find())
EndIf
EndIf
ForEach find()
If find()\dwFileAttributes & #FILE_ATTRIBUTE_DIRECTORY
AddGadgetItem(0, -1, "[DIR] " + find()\cFileName, 0, depth)
FtpListAll(hConnect, folder + find()\cFileName + "/", depth + 1)
Else
PokeL(@Size + 4, find()\nFileSizeLow)
PokeL(@Size + 0, find()\nFileSizeHigh)
AddGadgetItem(0, -1, "[FILE] " + find()\cFileName + " (" + StrByteSize(Size) + ")", 0, depth)
EndIf
Next
EndProcedure
;============================================
Define ftp.l, conn.l
If OpenWindow(0, 0, 0, 640, 480, "Ftp", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
TreeGadget(0, 10, 10, 620, 460, #PB_Tree_AlwaysShowSelection)
EndIf
ftp = FtpOpen()
If ftp
conn = FtpConnect(ftp, "localhost", "user", "pwd")
If conn
FtpListAll(conn, "/") ; <---- recursive proc
FtpDisconnect(conn)
EndIf
FtpClose(ftp)
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow: Break
Case #PB_Event_SizeWindow: ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0)-20, WindowHeight(0)-20)
EndSelect
ForEver
EndIf
;============================================