#include <SFML/Network/Export.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/Types.h>
#include <stddef.h>
Go to the source code of this file.
Functions | |
void | sfFtpListingResponse_destroy (sfFtpListingResponse *ftpListingResponse) |
Destroy a FTP listing response. | |
sfBool | sfFtpListingResponse_isOk (const sfFtpListingResponse *ftpListingResponse) |
Check if a FTP listing response status code means a success. | |
sfFtpStatus | sfFtpListingResponse_getStatus (const sfFtpListingResponse *ftpListingResponse) |
Get the status code of a FTP listing response. | |
const char * | sfFtpListingResponse_getMessage (const sfFtpListingResponse *ftpListingResponse) |
Get the full message contained in a FTP listing response. | |
size_t | sfFtpListingResponse_getCount (const sfFtpListingResponse *ftpListingResponse) |
Return the number of directory/file names contained in a FTP listing response. | |
const char * | sfFtpListingResponse_getName (const sfFtpListingResponse *ftpListingResponse, size_t index) |
Return a directory/file name contained in a FTP listing response. | |
void | sfFtpDirectoryResponse_destroy (sfFtpDirectoryResponse *ftpDirectoryResponse) |
Destroy a FTP directory response. | |
sfBool | sfFtpDirectoryResponse_isOk (const sfFtpDirectoryResponse *ftpDirectoryResponse) |
Check if a FTP directory response status code means a success. | |
sfFtpStatus | sfFtpDirectoryResponse_getStatus (const sfFtpDirectoryResponse *ftpDirectoryResponse) |
Get the status code of a FTP directory response. | |
const char * | sfFtpDirectoryResponse_getMessage (const sfFtpDirectoryResponse *ftpDirectoryResponse) |
Get the full message contained in a FTP directory response. | |
const char * | sfFtpDirectoryResponse_getDirectory (const sfFtpDirectoryResponse *ftpDirectoryResponse) |
Get the directory returned in a FTP directory response. | |
void | sfFtpResponse_destroy (sfFtpResponse *ftpResponse) |
Destroy a FTP response. | |
sfBool | sfFtpResponse_isOk (const sfFtpResponse *ftpResponse) |
Check if a FTP response status code means a success. | |
sfFtpStatus | sfFtpResponse_getStatus (const sfFtpResponse *ftpResponse) |
Get the status code of a FTP response. | |
const char * | sfFtpResponse_getMessage (const sfFtpResponse *ftpResponse) |
Get the full message contained in a FTP response. | |
sfFtp * | sfFtp_create (void) |
Create a new Ftp object. | |
void | sfFtp_destroy (sfFtp *ftp) |
Destroy a Ftp object. | |
sfFtpResponse * | sfFtp_connect (sfFtp *ftp, sfIpAddress server, unsigned short port, sfTime timeout) |
Connect to the specified FTP server. | |
sfFtpResponse * | sfFtp_loginAnonymous (sfFtp *ftp) |
Log in using an anonymous account. | |
sfFtpResponse * | sfFtp_login (sfFtp *ftp, const char *name, const char *password) |
Log in using a username and a password. | |
sfFtpResponse * | sfFtp_disconnect (sfFtp *ftp) |
Close the connection with the server. | |
sfFtpResponse * | sfFtp_keepAlive (sfFtp *ftp) |
Send a null command to keep the connection alive. | |
sfFtpDirectoryResponse * | sfFtp_getWorkingDirectory (sfFtp *ftp) |
Get the current working directory. | |
sfFtpListingResponse * | sfFtp_getDirectoryListing (sfFtp *ftp, const char *directory) |
Get the contents of the given directory. | |
sfFtpResponse * | sfFtp_changeDirectory (sfFtp *ftp, const char *directory) |
Change the current working directory. | |
sfFtpResponse * | sfFtp_parentDirectory (sfFtp *ftp) |
Go to the parent directory of the current one. | |
sfFtpResponse * | sfFtp_createDirectory (sfFtp *ftp, const char *name) |
Create a new directory. | |
sfFtpResponse * | sfFtp_deleteDirectory (sfFtp *ftp, const char *name) |
Remove an existing directory. | |
sfFtpResponse * | sfFtp_renameFile (sfFtp *ftp, const char *file, const char *newName) |
Rename an existing file. | |
sfFtpResponse * | sfFtp_deleteFile (sfFtp *ftp, const char *name) |
Remove an existing file. | |
sfFtpResponse * | sfFtp_download (sfFtp *ftp, const char *remoteFile, const char *localPath, sfFtpTransferMode mode) |
Download a file from a FTP server. | |
sfFtpResponse * | sfFtp_upload (sfFtp *ftp, const char *localFile, const char *remotePath, sfFtpTransferMode mode, sfBool append) |
Upload a file to a FTP server. | |
sfFtpResponse * | sfFtp_sendCommand (sfFtp *ftp, const char *command, const char *parameter) |
Send a command to the FTP server. | |
Enumeration Type Documentation
◆ sfFtpStatus
enum sfFtpStatus |
Status codes possibly returned by a FTP response.
◆ sfFtpTransferMode
enum sfFtpTransferMode |
Function Documentation
◆ sfFtp_changeDirectory()
sfFtpResponse * sfFtp_changeDirectory | ( | sfFtp * | ftp, |
const char * | directory | ||
) |
Change the current working directory.
The new directory must be relative to the current one.
- Parameters
-
ftp Ftp object directory New working directory
- Returns
- Server response to the request
◆ sfFtp_connect()
sfFtpResponse * sfFtp_connect | ( | sfFtp * | ftp, |
sfIpAddress | server, | ||
unsigned short | port, | ||
sfTime | timeout | ||
) |
Connect to the specified FTP server.
The port should be 21, which is the standard port used by the FTP protocol. You shouldn't use a different value, unless you really know what you do. This function tries to connect to the server so it may take a while to complete, especially if the server is not reachable. To avoid blocking your application for too long, you can use a timeout. Using 0 means that the system timeout will be used (which is usually pretty long).
- Parameters
-
ftp Ftp object server Name or address of the FTP server to connect to port Port used for the connection timeout Maximum time to wait
- Returns
- Server response to the request
◆ sfFtp_create()
sfFtp * sfFtp_create | ( | void | ) |
Create a new Ftp object.
- Returns
- A new sfFtp object
◆ sfFtp_createDirectory()
sfFtpResponse * sfFtp_createDirectory | ( | sfFtp * | ftp, |
const char * | name | ||
) |
Create a new directory.
The new directory is created as a child of the current working directory.
- Parameters
-
ftp Ftp object name Name of the directory to create
- Returns
- Server response to the request
◆ sfFtp_deleteDirectory()
sfFtpResponse * sfFtp_deleteDirectory | ( | sfFtp * | ftp, |
const char * | name | ||
) |
Remove an existing directory.
The directory to remove must be relative to the current working directory. Use this function with caution, the directory will be removed permanently!
- Parameters
-
ftp Ftp object name Name of the directory to remove
- Returns
- Server response to the request
◆ sfFtp_deleteFile()
sfFtpResponse * sfFtp_deleteFile | ( | sfFtp * | ftp, |
const char * | name | ||
) |
Remove an existing file.
The file name must be relative to the current working directory. Use this function with caution, the file will be removed permanently!
- Parameters
-
ftp Ftp object name File to remove
- Returns
- Server response to the request
◆ sfFtp_destroy()
void sfFtp_destroy | ( | sfFtp * | ftp | ) |
Destroy a Ftp object.
- Parameters
-
ftp Ftp object to destroy
◆ sfFtp_disconnect()
sfFtpResponse * sfFtp_disconnect | ( | sfFtp * | ftp | ) |
Close the connection with the server.
- Parameters
-
ftp Ftp object
- Returns
- Server response to the request
◆ sfFtp_download()
sfFtpResponse * sfFtp_download | ( | sfFtp * | ftp, |
const char * | remoteFile, | ||
const char * | localPath, | ||
sfFtpTransferMode | mode | ||
) |
Download a file from a FTP server.
The filename of the distant file is relative to the current working directory of the server, and the local destination path is relative to the current directory of your application.
- Parameters
-
ftp Ftp object remoteFile Filename of the distant file to download localPath Where to put to file on the local computer mode Transfer mode
- Returns
- Server response to the request
◆ sfFtp_getDirectoryListing()
sfFtpListingResponse * sfFtp_getDirectoryListing | ( | sfFtp * | ftp, |
const char * | directory | ||
) |
Get the contents of the given directory.
This function retrieves the sub-directories and files contained in the given directory. It is not recursive. The directory parameter is relative to the current working directory.
- Parameters
-
ftp Ftp object directory Directory to list
- Returns
- Server response to the request
◆ sfFtp_getWorkingDirectory()
sfFtpDirectoryResponse * sfFtp_getWorkingDirectory | ( | sfFtp * | ftp | ) |
Get the current working directory.
The working directory is the root path for subsequent operations involving directories and/or filenames.
- Parameters
-
ftp Ftp object
- Returns
- Server response to the request
◆ sfFtp_keepAlive()
sfFtpResponse * sfFtp_keepAlive | ( | sfFtp * | ftp | ) |
Send a null command to keep the connection alive.
This command is useful because the server may close the connection automatically if no command is sent.
- Parameters
-
ftp Ftp object
- Returns
- Server response to the request
◆ sfFtp_login()
sfFtpResponse * sfFtp_login | ( | sfFtp * | ftp, |
const char * | name, | ||
const char * | password | ||
) |
Log in using a username and a password.
Logging in is mandatory after connecting to the server. Users that are not logged in cannot perform any operation.
- Parameters
-
ftp Ftp object name User name password Password
- Returns
- Server response to the request
◆ sfFtp_loginAnonymous()
sfFtpResponse * sfFtp_loginAnonymous | ( | sfFtp * | ftp | ) |
Log in using an anonymous account.
Logging in is mandatory after connecting to the server. Users that are not logged in cannot perform any operation.
- Parameters
-
ftp Ftp object
- Returns
- Server response to the request
◆ sfFtp_parentDirectory()
sfFtpResponse * sfFtp_parentDirectory | ( | sfFtp * | ftp | ) |
Go to the parent directory of the current one.
- Parameters
-
ftp Ftp object
- Returns
- Server response to the request
◆ sfFtp_renameFile()
sfFtpResponse * sfFtp_renameFile | ( | sfFtp * | ftp, |
const char * | file, | ||
const char * | newName | ||
) |
Rename an existing file.
The filenames must be relative to the current working directory.
- Parameters
-
ftp Ftp object file File to rename newName New name of the file
- Returns
- Server response to the request
◆ sfFtp_sendCommand()
sfFtpResponse * sfFtp_sendCommand | ( | sfFtp * | ftp, |
const char * | command, | ||
const char * | parameter | ||
) |
Send a command to the FTP server.
While the most often used commands are provided as specific functions, this function can be used to send any FTP command to the server. If the command requires one or more parameters, they can be specified in parameter. Otherwise you should pass NULL. If the server returns information, you can extract it from the response using sfResponse_getMessage().
- Parameters
-
ftp Ftp object command Command to send parameter Command parameter
- Returns
- Server response to the request
◆ sfFtp_upload()
sfFtpResponse * sfFtp_upload | ( | sfFtp * | ftp, |
const char * | localFile, | ||
const char * | remotePath, | ||
sfFtpTransferMode | mode, | ||
sfBool | append | ||
) |
Upload a file to a FTP server.
The name of the local file is relative to the current working directory of your application, and the remote path is relative to the current directory of the FTP server.
- Parameters
-
ftp Ftp object localFile Path of the local file to upload remotePath Where to put to file on the server mode Transfer mode append Pass sfTrue to append to or sfFalse to overwrite the remote file if it already exists
- Returns
- Server response to the request
◆ sfFtpDirectoryResponse_destroy()
void sfFtpDirectoryResponse_destroy | ( | sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |
Destroy a FTP directory response.
- Parameters
-
ftpDirectoryResponse Ftp directory response to destroy
◆ sfFtpDirectoryResponse_getDirectory()
const char * sfFtpDirectoryResponse_getDirectory | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |
Get the directory returned in a FTP directory response.
- Parameters
-
ftpDirectoryResponse Ftp directory response
- Returns
- Directory name
◆ sfFtpDirectoryResponse_getMessage()
const char * sfFtpDirectoryResponse_getMessage | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |
Get the full message contained in a FTP directory response.
- Parameters
-
ftpDirectoryResponse Ftp directory response
- Returns
- The response message
◆ sfFtpDirectoryResponse_getStatus()
sfFtpStatus sfFtpDirectoryResponse_getStatus | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |
Get the status code of a FTP directory response.
- Parameters
-
ftpDirectoryResponse Ftp directory response
- Returns
- Status code
◆ sfFtpDirectoryResponse_isOk()
sfBool sfFtpDirectoryResponse_isOk | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |
Check if a FTP directory response status code means a success.
This function is defined for convenience, it is equivalent to testing if the status code is < 400.
- Parameters
-
ftpDirectoryResponse Ftp directory response
- Returns
- sfTrue if the status is a success, sfFalse if it is a failure
◆ sfFtpListingResponse_destroy()
void sfFtpListingResponse_destroy | ( | sfFtpListingResponse * | ftpListingResponse | ) |
Destroy a FTP listing response.
- Parameters
-
ftpListingResponse Ftp listing response to destroy
◆ sfFtpListingResponse_getCount()
size_t sfFtpListingResponse_getCount | ( | const sfFtpListingResponse * | ftpListingResponse | ) |
Return the number of directory/file names contained in a FTP listing response.
- Parameters
-
ftpListingResponse Ftp listing response
- Returns
- Total number of names available
◆ sfFtpListingResponse_getMessage()
const char * sfFtpListingResponse_getMessage | ( | const sfFtpListingResponse * | ftpListingResponse | ) |
Get the full message contained in a FTP listing response.
- Parameters
-
ftpListingResponse Ftp listing response
- Returns
- The response message
◆ sfFtpListingResponse_getName()
const char * sfFtpListingResponse_getName | ( | const sfFtpListingResponse * | ftpListingResponse, |
size_t | index | ||
) |
Return a directory/file name contained in a FTP listing response.
- Parameters
-
ftpListingResponse Ftp listing response index Index of the name to get (in range [0 .. getCount])
- Returns
- The requested name
◆ sfFtpListingResponse_getStatus()
sfFtpStatus sfFtpListingResponse_getStatus | ( | const sfFtpListingResponse * | ftpListingResponse | ) |
Get the status code of a FTP listing response.
- Parameters
-
ftpListingResponse Ftp listing response
- Returns
- Status code
◆ sfFtpListingResponse_isOk()
sfBool sfFtpListingResponse_isOk | ( | const sfFtpListingResponse * | ftpListingResponse | ) |
Check if a FTP listing response status code means a success.
This function is defined for convenience, it is equivalent to testing if the status code is < 400.
- Parameters
-
ftpListingResponse Ftp listing response
- Returns
- sfTrue if the status is a success, sfFalse if it is a failure
◆ sfFtpResponse_destroy()
void sfFtpResponse_destroy | ( | sfFtpResponse * | ftpResponse | ) |
Destroy a FTP response.
- Parameters
-
ftpResponse Ftp response to destroy
◆ sfFtpResponse_getMessage()
const char * sfFtpResponse_getMessage | ( | const sfFtpResponse * | ftpResponse | ) |
Get the full message contained in a FTP response.
- Parameters
-
ftpResponse Ftp response object
- Returns
- The response message
◆ sfFtpResponse_getStatus()
sfFtpStatus sfFtpResponse_getStatus | ( | const sfFtpResponse * | ftpResponse | ) |
Get the status code of a FTP response.
- Parameters
-
ftpResponse Ftp response object
- Returns
- Status code
◆ sfFtpResponse_isOk()
sfBool sfFtpResponse_isOk | ( | const sfFtpResponse * | ftpResponse | ) |
Check if a FTP response status code means a success.
This function is defined for convenience, it is equivalent to testing if the status code is < 400.
- Parameters
-
ftpResponse Ftp response object
- Returns
- sfTrue if the status is a success, sfFalse if it is a failure