DataFlex
DataFlex
Get an FTP Listing Entry's Group
See more FTP Examples
Demonstrates the Chilkat Ftp2.GetGroup method, which returns the group name or identifier of a cached directory-listing entry. The only argument is a zero-based index. The value is empty when the server does not provide group metadata.
Background: The group is the counterpart to the owner in Unix-style ownership, driving the "group" permission bits. Like the owner, it is only present when the server's listing format includes it, and may be reported as a numeric GID. An empty value simply means the metadata was not provided.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
Integer n
Integer i
String sName
String sGroup
String sTemp1
Move False To iSuccess
// Demonstrates the Ftp2.GetGroup method, which returns the group name or identifier of a cached
// directory-listing entry. The only argument is a zero-based index.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
Set ComPassword Of hoFtp To "myPassword"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComChangeRemoteDir Of hoFtp "public_html" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// GetDirCount retrieves the directory listing on the first call and returns the number of
// entries. A negative return indicates failure.
Get ComGetDirCount Of hoFtp To n
If (n < 0) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
For i From 0 To (n - 1)
Get ComGetFilename Of hoFtp i To sName
// The group is empty when the server does not provide group metadata.
Get ComGetGroup Of hoFtp i To sGroup
Showln sGroup " " sName
Loop
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure