OpenFTP not work on 6.21

Post bugreports for the Windows version here
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

OpenFTP not work on 6.21

Post 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.
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OpenFTP not work on 6.21

Post 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
Last edited by infratec on Sun Jul 13, 2025 3:58 pm, edited 2 times in total.
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: OpenFTP not work on 6.21

Post 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

....
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OpenFTP not work on 6.21

Post 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?
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: OpenFTP not work on 6.21

Post 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 ?
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OpenFTP not work on 6.21

Post 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/"
Last edited by infratec on Sun Jul 13, 2025 5:53 pm, edited 1 time in total.
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: OpenFTP not work on 6.21

Post 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.
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OpenFTP not work on 6.21

Post 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
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: OpenFTP not work on 6.21

Post 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...
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OpenFTP not work on 6.21

Post by infratec »

I added 2 examples to the libcurl zip file.
You can only remove empty directories.
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: OpenFTP not work on 6.21

Post 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...
Post Reply