Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Ftp Source Code
 previous   up   next 

Types
ftpFileSys
Extended FileSys interface type for FTP file systems.
ftpConnection
ftpFileSys implementation type for a connection to a FTP server.

ftpFileSys

const type: ftpFileSys

Extended FileSys interface type for FTP file systems. This interface type allows access to FTP specific methods: listDir, getActiveMode, setActiveMode, getAsciiTransfer, setAsciiTransfer. If this methods are not needed the interface type fileSys can be used instead.


ftpConnection

const type: ftpConnection

ftpFileSys implementation type for a connection to a FTP server. The file system methods trigger requests to the FTP server.


Function Summary
ftpFileSys
openFtp (in string: hostName, in string: user, in string: password, in integer: ftpControlPort)
Open a FTP file system at the specified host, user and port.
ftpFileSys
openFtp (in string: hostName, in string: user, in string: password)
Open a FTP file system at the specified host and user.
ftpFileSys
openFtp (in string: connectStri, in integer: ftpControlPort)
Open a FTP file system with the specified connectStri and port.
ftpFileSys
openFtp (in string: connectStri)
Open a FTP file system with the specified connectStri.
void
close (inout ftpConnection: ftp)
Close a FTP connection.
array string
readDir (inout ftpConnection: ftp, in string: dirPath)
Determine the filenames in a directory, using a FTP connection.
array string
listDir (inout ftpConnection: ftp, in string: dirPath)
Get a directory listing, using a FTP connection.
void
chdir (inout ftpConnection: ftp, in string: dirName)
Change the current working directory of a FTP connection.
string
getcwd (inout ftpConnection: ftp)
Determine the current working directory of a FTP connection.
fileType
fileType (inout ftpConnection: ftp, in string: fileName)
Determine the type of a file.
fileType
fileTypeSL (inout ftpConnection: ftp, in string: fileName)
Determine the type of a file.
integer
fileSize (inout ftpConnection: ftp, in string: fileName)
Determine the file size of a file.
bigInteger
bigFileSize (inout ftpConnection: ftp, in string: fileName)
Determine the file size of a file.
time
getMTime (inout ftpConnection: ftp, in string: fileName)
Determine the modification time of a file.
boolean
getActiveMode (in ftpConnection: ftp)
Get the the data transfer mode.
void
setActiveMode (inout ftpConnection: ftp, in boolean: activeMode)
Set the the data transfer mode to active (=TRUE) or passive (=FALSE).
boolean
getAsciiTransfer (in ftpConnection: ftp)
Get the file transfer type.
void
setAsciiTransfer (inout ftpConnection: ftp, in boolean: asciiTransfer)
Set the file transfer type to ASCII (=TRUE) or BINARY (=FALSE).
file
open (inout ftpConnection: ftp, in string: filePath, in string: mode)
Open a file with filePath and mode using a FTP connection.
string
getFile (inout ftpConnection: ftp, in string: filePath)
Get the contents of file filePath using a FTP connection.
void
putFile (inout ftpConnection: ftp, in string: filePath, in string: stri)
Write stri to remote file filePath using a FTP connection.
void
removeFile (inout ftpConnection: ftp, in string: fileName)
Remove a file using a FTP connection.
void
moveFile (inout ftpConnection: ftp, in string: sourcePath, in string: destPath)
Rename a file using a FTP connection.
void
mkdir (inout ftpConnection: ftp, in string: dirName)
Creates a directory on a remote host using a FTP connection.
void
rmdir (inout ftpConnection: ftp, in string: dirName)
Deletes an empty directory using a FTP connection.
string
getFtp (in string: url)
Get data specified by an URL using the FTP protocol.

Function Detail

openFtp

const func ftpFileSys: openFtp (in string: hostName, in string: user, in string: password, in integer: ftpControlPort)

Open a FTP file system at the specified host, user and port.

Parameters:
hostName - Either a host name ("e.g.: "www.example.org"), or an IPv4 address in standard dot notation (e.g.: "192.0.2.235"), or an IPv6 address in colon notation.
user - Username to be used for the login.
password - Password to be used for the login.
ftpControlPort - Port to be used for the control connection. FTP usually uses the port 21, but other ports can also be specified.
Returns:
a file system that uses the FTP connection, or fileSys.value if the connection to the remote host could not be established.

openFtp

const func ftpFileSys: openFtp (in string: hostName, in string: user, in string: password)

Open a FTP file system at the specified host and user. This function uses port 21.

Parameters:
hostName - Either a host name ("e.g.: "www.example.org"), or an IPv4 address in standard dot notation (e.g.: "192.0.2.235"), or an IPv6 address in colon notation.
user - Username to be used for the login.
password - Password to be used for the login.
Returns:
a file system that uses the FTP connection, or fileSys.value if the connection to the remote host could not be established.

openFtp

const func ftpFileSys: openFtp (in string: connectStri, in integer: ftpControlPort)

Open a FTP file system with the specified connectStri and port. The connectStri should be in the form

user:password@hostName

to specify user and password. If no password is specified the password "anonymous" is used instead:

user@hostName

When no user and password are specified the user "anonymous" is used together with the password "anonymous":

hostName

The hostName is either a host name ("e.g.: "www.example.org"), or an IPv4 address in standard dot notation (e.g.: "192.0.2.235"). Operating systems supporting IPv6 may also accept an IPv6 address in colon notation.

Parameters:
connectStri - Connection string in one of the forms user:password@hostName user@hostName or hostName When no user is specified the user "anonymous" is used. When no password is specified the password "anonymous" is used.
Returns:
a file system that uses the FTP connection, or fileSys.value if the connection to the remote host could not be established.

openFtp

const func ftpFileSys: openFtp (in string: connectStri)

Open a FTP file system with the specified connectStri. The connectStri should be in the form

user:password@hostName

to specify user and password. If no password is specified the password "anonymous" is used instead:

user@hostName

When no user and password are specified the user "anonymous" is used together with the password "anonymous":

hostName

This function uses the port 21 (defined as defaultFtpControlPort). The hostName is either a host name ("e.g.: "www.example.org"), or an IPv4 address in standard dot notation (e.g.: "192.0.2.235"). Operating systems supporting IPv6 may also accept an IPv6 address in colon notation.

Parameters:
connectStri - Connection string in one of the forms user:password@hostName user@hostName or hostName When no user is specified the user "anomymous" is used. When no password is specified the password "anomymous" is used.
Returns:
a file system that uses the FTP connection, or fileSys.value if the connection to the remote host could not be established.

close

const proc: close (inout ftpConnection: ftp)

Close a FTP connection.


readDir

const func array string: readDir (inout ftpConnection: ftp, in string: dirPath)

Determine the filenames in a directory, using a FTP connection.

Returns:
an array with the file names.
Raises:
FILE_ERROR - The remote host returns an error.

listDir

const func array string: listDir (inout ftpConnection: ftp, in string: dirPath)

Get a directory listing, using a FTP connection.

Returns:
an array with the file names.
Raises:
FILE_ERROR - The remote host returns an error.

chdir

const proc: chdir (inout ftpConnection: ftp, in string: dirName)

Change the current working directory of a FTP connection.

Raises:
FILE_ERROR - The remote host returns an error.

getcwd

const func string: getcwd (inout ftpConnection: ftp)

Determine the current working directory of a FTP connection.

Returns:
the current working directory as absolute path.
Raises:
FILE_ERROR - The remote host returns an error.

fileType

const func fileType: fileType (inout ftpConnection: ftp, in string: fileName)

Determine the type of a file. The function does follow symbolic links. Therefore it never returns FILE_SYMLINK. A return value of FILE_ABSENT does not imply that a file with this name can be created, since missing directories and illegal file names cause also FILE_ABSENT.

Returns:
the type of the file.

fileTypeSL

const func fileType: fileTypeSL (inout ftpConnection: ftp, in string: fileName)

Determine the type of a file. Since in FTP symbolic links are not defined this function is identical to fileType.

Returns:
the type of the file.

fileSize

const func integer: fileSize (inout ftpConnection: ftp, in string: fileName)

Determine the file size of a file. The file size is measured in bytes.

Returns:
the size of the file.

bigFileSize

const func bigInteger: bigFileSize (inout ftpConnection: ftp, in string: fileName)

Determine the file size of a file. The file size is measured in bytes.

Returns:
the size of the file.

getMTime

const func time: getMTime (inout ftpConnection: ftp, in string: fileName)

Determine the modification time of a file.

Returns:
the modification time of the file.
Raises:
RANGE_ERROR - the modification time is not representable in the type time.

getActiveMode

const func boolean: getActiveMode (in ftpConnection: ftp)

Get the the data transfer mode.

Returns:
TRUE, when the transfer mode is active, or FALSE, when the transfer mode is passive.

setActiveMode

const proc: setActiveMode (inout ftpConnection: ftp, in boolean: activeMode)

Set the the data transfer mode to active (=TRUE) or passive (=FALSE). By default passive mode is used.


getAsciiTransfer

const func boolean: getAsciiTransfer (in ftpConnection: ftp)

Get the file transfer type.

Returns:
TRUE, when the file transfer type is ASCII, or FALSE, when the file transfer type is BINARY.

setAsciiTransfer

const proc: setAsciiTransfer (inout ftpConnection: ftp, in boolean: asciiTransfer)

Set the file transfer type to ASCII (=TRUE) or BINARY (=FALSE). By default binary transfer is used.


open

const func file: open (inout ftpConnection: ftp, in string: filePath, in string: mode)

Open a file with filePath and mode using a FTP connection. There are text modes and binary modes:

  • Binary modes:
    • "r" Open file for reading.
    • "w" Truncate to zero length or create file for writing.
  • Text modes:
    • "rt" Open file for reading.
    • "wt" Truncate to zero length or create file for writing.

No other FTP functions can be used while reading and writing this file is going on. After this file has been closed other FTP functions can be used.

Raises:
RANGE_ERROR - The mode is not one of the allowed values or path does not use the standard path representation

getFile

const func string: getFile (inout ftpConnection: ftp, in string: filePath)

Get the contents of file filePath using a FTP connection.

Returns:
the specified file as string.
Raises:
FILE_ERROR - The remote host returns an error.

putFile

const proc: putFile (inout ftpConnection: ftp, in string: filePath, in string: stri)

Write stri to remote file filePath using a FTP connection. If the file exists already, it is overwritten.

Raises:
FILE_ERROR - The remote host returns an error.

removeFile

const proc: removeFile (inout ftpConnection: ftp, in string: fileName)

Remove a file using a FTP connection.

Raises:
FILE_ERROR - The remote host returns an error.

moveFile

const proc: moveFile (inout ftpConnection: ftp, in string: sourcePath, in string: destPath)

Rename a file using a FTP connection.

Raises:
FILE_ERROR - The remote host returns an error.

mkdir

const proc: mkdir (inout ftpConnection: ftp, in string: dirName)

Creates a directory on a remote host using a FTP connection.

Raises:
FILE_ERROR - The remote host returns an error.

rmdir

const proc: rmdir (inout ftpConnection: ftp, in string: dirName)

Deletes an empty directory using a FTP connection.

Raises:
FILE_ERROR - The remote host returns an error.

getFtp

const func string: getFtp (in string: url)

Get data specified by an URL using the FTP protocol. The contents of the file "/pub/read_me.txt" can be obtained from the computer www.example.org with:

fileContent := getFtp("www.example.org/pub/read_me.txt");

User and password can be specified with:

fileContent := getFtp("user:password@www.example.org/pub/read_me.txt");
Returns:
the string of data found, or "" when nothing was found.


 previous   up   next