Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/FTP/CURLS ftp directory listing with wildcard
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/FTP/CURLS ftp directory listing with wildcard
This example is the version from Wed, 3rd Jan 2023.
Project "CURLS ftp directory listing with wildcard.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
DoDownload
End EventHandler
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control DebugMessages Inherits TextArea
ControlInstance DebugMessages Inherits TextArea
EventHandler Sub Open()
me.Visible = False
me.Height = list.Height
me.top = List.top
End EventHandler
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control StaticText111 Inherits Label
ControlInstance StaticText111 Inherits Label
End Control
Control NameField Inherits TextField
ControlInstance NameField Inherits TextField
End Control
Control PassField Inherits TextField
ControlInstance PassField Inherits TextField
End Control
EventHandler Sub Open()
List.ColumnAlignment(2) = List.AlignRight
List.ColumnAlignment(3) = List.AlignRight
List.ColumnAlignment(4) = List.AlignRight
List.ColumnAlignment(5) = List.AlignRight
List.ColumnAlignment(6) = List.AlignRight
List.ColumnAlignment(8) = List.AlignRight
End EventHandler
Private Sub DoDownload()
dim URL as string = self.url.Text
if Right(URL,1) = "*" then
// ok
else
if Right(URL,1) = "/" then
// ok, but add *
url = url + "*"
else
// add / and *
url = url + "/*"
end if
end if
List.DeleteAllRows
dim s as string
dim e as integer
dim d as new CURLSMBS
d.CollectDebugMessages = true
d.CollectOutputData = true
d.OptionVerbose = true
d.OptionURL = URL
d.OptionUsername = NameField.Text
d.OptionPassword = PassField.Text
// download multiple, but ChunkBegin event will skip all as we don't implement it!
d.OptionWildCardMatch = true
// make secure for SSL
'd.OptionUseSSL = d.kFTPSSL_ALL
'd.OptionSSLVerifyHost = 2
'd.OptionSSLVerifyPeer = 1
// or not secure
d.OptionUseSSL = d.kFTPSSL_NONE
d.OptionSSLVerifyHost = 0
d.OptionSSLVerifyPeer = 0
e = d.Perform
select case e
case 0
s = " = OK"
dim files() as CURLSFileInfoMBS = d.FileInfos
for each f as CURLSFileInfoMBS in files
dim TheSize as string = Format(f.Size, "0")
dim type as string
Select case f.FileType
case f.FileTypeDeviceBlock
type = "DeviceBlock"
case f.FileTypeDeviceChar
type = "DeviceChar"
case f.FileTypeDirectory
type = "Directory"
case f.FileTypeDoor
type = "Door"
case f.FileTypeFile
type = "File"
case f.FileTypeNamedPipe
type = "NamedPipe"
case f.FileTypeSocket
type = "Socket"
case f.FileTypeSymlink
type = "Symlink"
else
Break
end Select
dim TheDates as string
dim TheDate as date = f.Date
if TheDate <> nil then
TheDates = TheDate.SQLDateTime
end if
dim UID as string
if f.HasUID then
UID = str(f.UID)
end if
dim GID as string
if f.HasGID then
GID = str(f.GID)
end if
dim HardLinks as string
if f.HasHardLinks then
HardLinks = str(f.HardLinks)
end if
List.AddRow f.FileName, type, TheSize, TheDates, f.PermissionString, UID, GID, f.Target, HardLinks
next
case d.kError_COULDNT_CONNECT
s=" = Couldn't connect."
case 9
s=" = Access Denied"
case d.kError_LOGIN_DENIED
s=" = Login Denied"
case d.kError_REMOTE_FILE_NOT_FOUND
s=" = File not found."
else
s=""
Break
end select
if e = 0 then
List.Visible = true
DebugMessages.Visible = false
else
dim de as string = d.DebugMessages
if de.Encoding = nil then
de = DefineEncoding(de, encodings.ISOLatin1)
end if
DebugMessages.Text = de
List.Visible = false
DebugMessages.Visible = true
end if
ResultText.text="Result: "+str(e)+s
End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
End Project
See also:
- /CURL/FTP/CURLS ftp directory listing
- /CURL/FTP/CURLS ftp directory listing with CURLFileInfoMBS
- /CURL/FTP/CURLS ftp directory listing with Web Edition
- /CURL/FTP/CURLS ftp download to desktop
- /CURL/FTP/CURLS ftp file upload
- /CURL/FTP/CURLS ftp file upload resume
- /CURL/FTP/CURLS ftp file upload with thread
- /CURL/FTP/CURLS ftp file uploads
- /CURL/FTP/CURLS ftp secure upload
- /CURL/FTP/CURLS ftp upload
The items on this page are in the following plugins: MBS CURL Plugin.