Writes list of FTP directory contents to passed Fortran file unit
unit
.
The following example writes the contents of the FTP root directory to a scratch file and outputs the file afterwards:
character(len=512) :: line
integer :: rc, stat, unit
type(ftp_server_type) :: server
open (action='readwrite', form='formatted', newunit=unit, status='scratch')
rc = dm_ftp_init()
call dm_ftp_server_set(server, host='localhost', username='user', password='secret', tls=.false.)
rc = dm_ftp_list(server, unit, '/', names_only=.true.)
call dm_ftp_shutdown()
rewind (unit)
do
read (unit, '(a)', iostat=stat) line
if (stat /= 0) exit
print '(a)', trim(line)
end do
close (unit)
The function returns the following error codes:
E_COMPILER
if C pointers could not be nullified (compiler bug).E_FTP
if initialisation or connection failed.E_FTP_AUTH
if FTP authentication failed.E_FTP_CONNECT
if connection to server could not be established.E_FTP_SSL
if SSL/TLS error occured.E_INVALID
if arguments or FTP server type attributes are invalid.E_IO
if unit is not opened.Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ftp_server_type), | intent(inout) | :: | server |
FTP server type. |
||
integer, | intent(in) | :: | unit |
File unit to write to. |
||
character(len=*), | intent(in) | :: | directory |
Path of remote FTP directory. |
||
logical, | intent(in), | optional | :: | names_only |
List only names (NLST command). |
|
logical, | intent(in), | optional | :: | debug |
Output debug messages. |
|
character(len=:), | intent(out), | optional, | allocatable | :: | error_message |
Error message. |
integer, | intent(out), | optional | :: | error_curl |
cURL error code. |