Page 1 of 1

OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 2:40 pm
by drgolf
Hello,

On windows 10 PRO x64, this line with :

serveur.s : ftpperso.free.fr
user.s : myident
pw.s : mypassword
port.i :21

Code: Select all

If OpenFTP(0,serveur,user,pw,#True,port) 

With PB 6.11 : all work well and i can list the files.
On PB 6.21 x64 ASM or C BE : unable to connect !!

With this line :

Code: Select all

If OpenFTP(0,serveur,user,pw)


I have connection but garbage on listing !!

There is changes between versions... What can i do for my application ?

This is an app that work very well previously, without any glitch.

Any help appreciated.

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 2:57 pm
by infratec
Works for me:

PB 6.21 x64

Code: Select all

If OpenFTP(0, "xxx.xx", "yyyy", "zzz", #True, 21)
  Debug "Ok"
  
  If ExamineFTPDirectory(0)
    While NextFTPDirectoryEntry(0)
      Debug FTPDirectoryEntryName(0)
    Wend
    FinishFTPDirectory(0)
  EndIf
  
  CloseFTP(0)
EndIf

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 3:28 pm
by drgolf
Hello,

For me no connexion on ftp serveur FREE.fr with 6.21 : openftp return 0
Connexion with the same app and same param with pb 6.11 on x64 or x86

....

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 4:09 pm
by infratec
Works here too:

PureBasic 6.21 (Windows - x64)
ASM and C backend

Code: Select all

serveur.s = "ftp.free.fr"
user.s = "anonymous"
pw.s = ""
port.i = 21

If OpenFTP(0, serveur, user, pw, #True, port)
  Debug "Open"
  
  If ExamineFTPDirectory(0)
    While NextFTPDirectoryEntry(0)
      Debug FTPDirectoryEntryName(0)
    Wend
    FinishFTPDirectory(0)
  EndIf
  
  CloseFTP(0)
Else
  Debug "Not open"
EndIf
->
Open
tmp
stats
pub
nzb
mirrors
lost+found
awstats
MPlayer -> mirrors/mplayerhq.hu/MPlayer
Please test exact this code. What's your result?

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 4:55 pm
by drgolf
@infratec with your code : same result, BUT with :

serveur.s = "ftpperso.free.fr"
user.s = "user"
pw.s = "pass"
port.i = 21

Code: Select all

If OpenFTP(0, serveur, user, pw, #True, port)
  Debug "Open"
  
  If ExamineFTPDirectory(0)
    While NextFTPDirectoryEntry(0)
      Debug FTPDirectoryEntryName(0)
    Wend
    FinishFTPDirectory(0)
  EndIf
  
  CloseFTP(0)
Else
  Debug "Not open"
EndIf
NOT Open.

With PB 6.11 : ftpperso >>> Open

Thanx for your help... Maybe with libcurl is it possible ?

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 5:23 pm
by infratec
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/"

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 5:53 pm
by drgolf
@infratec : all work fine with libcurl.... babababa... Its not easy to implement in my app... and very big dll...

I use libcurl for mail client... but for ftp client...

Thanx for your help.

In the libcurl zip the examples ftps_dir and ftps_getdirectory are the same files.

Re: OpenFTP not work on 6.21

Posted: Sun Jul 13, 2025 5:54 pm
by infratec
You don't need the external dll.

the used libcurl stuff is inbuild.
As I told you PB uses libcurl too.

An yes, I just removed FTPS_dir.pb

I added the example above as FTP_dir.pb

Re: OpenFTP not work on 6.21

Posted: Mon Jul 14, 2025 5:09 pm
by drgolf
@infratec,

There is a change in PB with FTP lib after version 6.11
My application work with PB11 but not with versions after.

So, i work on libcurl FTP... I can have the dir list.
How to create/delete dir with libcurl ?

Thanx by advance...

Re: OpenFTP not work on 6.21

Posted: Mon Jul 14, 2025 7:20 pm
by infratec
I added 2 examples to the libcurl zip file.
You can only remove empty directories.

Re: OpenFTP not work on 6.21

Posted: Wed Jul 23, 2025 9:38 am
by drgolf
Hi Infratec,

Thanx for examples using libcurl for rmdir and creaye dir...

Not easy to change my app with libcurl... big work...

My problem is for delete recursive dir not empty...