Strange ...
Of course you can try my libcurl.pbi
Maybe you get an error if it fails, or you can see what fails.
viewtopic.php?t=80118
Use the FTPS_GetDirectory.pb as base.
You can remove all SSL stuff.
And comment out #LibCurl_ExternalDLL = #True
Btw.: PB uses libcurl for FTP.
Or try this:
Code: Select all
EnableExplicit
IncludeFile "libcurl.pbi"
;#REMOTE_URL$ = "ftp://ftp.free.fr/stats/"
;#REMOTE_URL$ = "ftp://ftp.free.fr/tmp/"
#REMOTE_URL$ = "ftp://ftp.free.fr/"
#Username$ = "anonymous"
#Password$ = ""
Structure FTPDirStructure
Rights$
HardLinks.i
User$
Group$
Size.i
Date$
Name$
EndStructure
Define curl.i, res.i, Entries$, i.i, Line$
Define UserData.libcurl_userdata_structure
NewList DirList.FTPDirStructure()
CompilerIf #PB_Compiler_Version < 600
InitNetwork()
CompilerEndIf
curl_global_init(#CURL_GLOBAL_DEFAULT)
curl = curl_easy_init()
If curl
curl_easy_setopt_str(curl, #CURLOPT_URL, #REMOTE_URL$)
curl_easy_setopt_str(curl, #CURLOPT_USERNAME, #Username$)
curl_easy_setopt_str(curl, #CURLOPT_PASSWORD, #Password$)
curl_easy_setopt(curl, #CURLOPT_FTP_USE_EPSV, 0) ; PASV
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @LibCurl_WriteFunction())
curl_easy_setopt(curl, #CURLOPT_WRITEDATA, @UserData)
curl_easy_setopt(curl, #CURLOPT_VERBOSE, #True)
res = curl_easy_perform(curl)
If res = #CURLE_OK
If UserData\Memory
;ShowMemoryViewer(UserData\Memory, MemorySize(UserData\Memory))
Entries$ = PeekS(UserData\Memory, MemorySize(UserData\Memory), #PB_UTF8|#PB_ByteLength)
;Debug Entries$
i = 1
Line$ = StringField(Entries$, i, #CRLF$)
While Line$ <> ""
AddElement(DirList())
DirList()\Rights$ = Left(Line$, 10)
Line$ = Mid(Line$, 11)
DirList()\HardLinks = Val(LTrim(Line$))
Line$ = Mid(Line$, 7)
DirList()\User$ = RTrim(Left(Line$, 9))
Line$ = Mid(Line$, 10)
DirList()\Group$ = RTrim(Left(Line$, 9))
Line$ = Mid(Line$, 11)
DirList()\Size = Val(LTrim(Line$))
Line$ = Mid(Line$, 9)
DirList()\Date$ = Left(Line$, 12)
DirList()\Name$ = Mid(Line$, 14)
i + 1
Line$ = StringField(Entries$, i, #CRLF$)
Wend
FreeMemory(UserData\Memory)
UserData\Memory = #Null
EndIf
Else
Debug "Error: " + curl_easy_strerror(res)
EndIf
curl_easy_cleanup(curl)
Else
MessageRequester("Error", "Was not able to init curl")
EndIf
curl_global_cleanup()
ForEach DirList()
Select Left(DirList()\Rights$, 1)
Case "-"
Debug "File: " + DirList()\Rights$ + " " + Str(DirList()\HardLinks) + " " + DirList()\User$ + " " + DirList()\Group$ + " " + Str(DirList()\Size) + " " + DirList()\Date$ + " " + DirList()\Name$
Case "d"
Debug "Dir : " + DirList()\Rights$ + " " + Str(DirList()\HardLinks) + " " + DirList()\User$ + " " + DirList()\Group$ + " " + Str(DirList()\Size) + " " + DirList()\Date$ + " " + DirList()\Name$
Case "l"
Debug "Link: " + DirList()\Rights$ + " " + Str(DirList()\HardLinks) + " " + DirList()\User$ + " " + DirList()\Group$ + " " + Str(DirList()\Size) + " " + DirList()\Date$ + " " + DirList()\Name$
EndSelect
Next
If you want to specify a port, you have to add it to the url:
Code: Select all
#REMOTE_URL = "ftp://ftp.free.fr:21/"