CSFML - C binding of the Simple and Fast Multimedia Library

CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Enumerations | Functions
Ftp.h File Reference
`#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.

## Enumerations
enum | sfFtpTransferMode { sfFtpBinary, sfFtpAscii, sfFtpEbcdic }
| Enumeration of transfer modes. More...
enum | sfFtpStatus { sfFtpRestartMarkerReply = 110, sfFtpServiceReadySoon = 120, sfFtpDataConnectionAlreadyOpened = 125, sfFtpOpeningDataConnection = 150, sfFtpOk = 200, sfFtpPointlessCommand = 202, sfFtpSystemStatus = 211, sfFtpDirectoryStatus = 212, sfFtpFileStatus = 213, sfFtpHelpMessage = 214, sfFtpSystemType = 215, sfFtpServiceReady = 220, sfFtpClosingConnection = 221, sfFtpDataConnectionOpened = 225, sfFtpClosingDataConnection = 226, sfFtpEnteringPassiveMode = 227, sfFtpLoggedIn = 230, sfFtpFileActionOk = 250, sfFtpDirectoryOk = 257, sfFtpNeedPassword = 331, sfFtpNeedAccountToLogIn = 332, sfFtpNeedInformation = 350, sfFtpServiceUnavailable = 421, sfFtpDataConnectionUnavailable = 425, sfFtpTransferAborted = 426, sfFtpFileActionAborted = 450, sfFtpLocalError = 451, sfFtpInsufficientStorageSpace = 452, sfFtpCommandUnknown = 500, sfFtpParametersUnknown = 501, sfFtpCommandNotImplemented = 502, sfFtpBadCommandSequence = 503, sfFtpParameterNotImplemented = 504, sfFtpNotLoggedIn = 530, sfFtpNeedAccountToStore = 532, sfFtpFileUnavailable = 550, sfFtpPageTypeUnknown = 551, sfFtpNotEnoughMemory = 552, sfFtpFilenameNotAllowed = 553, sfFtpInvalidResponse = 1000, sfFtpConnectionFailed = 1001, sfFtpConnectionClosed = 1002, sfFtpInvalidFile = 1003 }
| Status codes possibly returned by a FTP response. More...

## Functions
CSFML_NETWORK_API void | sfFtpListingResponse_destroy (sfFtpListingResponse *ftpListingResponse)
| Destroy a FTP listing response. More...
CSFML_NETWORK_API sfBool | sfFtpListingResponse_isOk (const sfFtpListingResponse *ftpListingResponse)
| Check if a FTP listing response status code means a success. More...
CSFML_NETWORK_API sfFtpStatus | sfFtpListingResponse_getStatus (const sfFtpListingResponse *ftpListingResponse)
| Get the status code of a FTP listing response. More...
CSFML_NETWORK_API const char * | sfFtpListingResponse_getMessage (const sfFtpListingResponse *ftpListingResponse)
| Get the full message contained in a FTP listing response. More...
CSFML_NETWORK_API size_t | sfFtpListingResponse_getCount (const sfFtpListingResponse *ftpListingResponse)
| Return the number of directory/file names contained in a FTP listing response. More...
CSFML_NETWORK_API const char * | sfFtpListingResponse_getName (const sfFtpListingResponse *ftpListingResponse, size_t index)
| Return a directory/file name contained in a FTP listing response. More...
CSFML_NETWORK_API void | sfFtpDirectoryResponse_destroy (sfFtpDirectoryResponse *ftpDirectoryResponse)
| Destroy a FTP directory response. More...
CSFML_NETWORK_API sfBool | sfFtpDirectoryResponse_isOk (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Check if a FTP directory response status code means a success. More...
CSFML_NETWORK_API sfFtpStatus | sfFtpDirectoryResponse_getStatus (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Get the status code of a FTP directory response. More...
CSFML_NETWORK_API const char * | sfFtpDirectoryResponse_getMessage (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Get the full message contained in a FTP directory response. More...
CSFML_NETWORK_API const char * | sfFtpDirectoryResponse_getDirectory (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Get the directory returned in a FTP directory response. More...
CSFML_NETWORK_API void | sfFtpResponse_destroy (sfFtpResponse *ftpResponse)
| Destroy a FTP response. More...
CSFML_NETWORK_API sfBool | sfFtpResponse_isOk (const sfFtpResponse *ftpResponse)
| Check if a FTP response status code means a success. More...
CSFML_NETWORK_API sfFtpStatus | sfFtpResponse_getStatus (const sfFtpResponse *ftpResponse)
| Get the status code of a FTP response. More...
CSFML_NETWORK_API const char * | sfFtpResponse_getMessage (const sfFtpResponse *ftpResponse)
| Get the full message contained in a FTP response. More...
CSFML_NETWORK_API sfFtp * | sfFtp_create (void)
| Create a new Ftp object. More...
CSFML_NETWORK_API void | sfFtp_destroy (sfFtp *ftp)
| Destroy a Ftp object. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_connect (sfFtp *ftp, sfIpAddress server, unsigned short port, sfTime timeout)
| Connect to the specified FTP server. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_loginAnonymous (sfFtp *ftp)
| Log in using an anonymous account. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_login (sfFtp *ftp, const char *userName, const char *password)
| Log in using a username and a password. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_disconnect (sfFtp *ftp)
| Close the connection with the server. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_keepAlive (sfFtp *ftp)
| Send a null command to keep the connection alive. More...
CSFML_NETWORK_API sfFtpDirectoryResponse * | sfFtp_getWorkingDirectory (sfFtp *ftp)
| Get the current working directory. More...
CSFML_NETWORK_API sfFtpListingResponse * | sfFtp_getDirectoryListing (sfFtp *ftp, const char *directory)
| Get the contents of the given directory. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_changeDirectory (sfFtp *ftp, const char *directory)
| Change the current working directory. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_parentDirectory (sfFtp *ftp)
| Go to the parent directory of the current one. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_createDirectory (sfFtp *ftp, const char *name)
| Create a new directory. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_deleteDirectory (sfFtp *ftp, const char *name)
| Remove an existing directory. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_renameFile (sfFtp *ftp, const char *file, const char *newName)
| Rename an existing file. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_deleteFile (sfFtp *ftp, const char *name)
| Remove an existing file. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_download (sfFtp *ftp, const char *distantFile, const char *destPath, sfFtpTransferMode mode)
| Download a file from a FTP server. More...
CSFML_NETWORK_API sfFtpResponse * | sfFtp_upload (sfFtp *ftp, const char *localFile, const char *destPath, sfFtpTransferMode mode)
| Upload a file to a FTP server. More...

## Enumeration Type Documentation

enum sfFtpStatus

Status codes possibly returned by a FTP response.

Enumerator
sfFtpRestartMarkerReply | Restart marker reply.
sfFtpServiceReadySoon | Service ready in N minutes.
sfFtpDataConnectionAlreadyOpened | Data connection already opened, transfer starting.
sfFtpOpeningDataConnection | File status ok, about to open data connection.
sfFtpOk | Command ok.
sfFtpPointlessCommand | Command not implemented.
sfFtpSystemStatus | System status, or system help reply.
sfFtpDirectoryStatus | Directory status.
sfFtpFileStatus | File status.
sfFtpHelpMessage | Help message.
sfFtpSystemType | NAME system type, where NAME is an official system name from the list in the Assigned Numbers document.
sfFtpServiceReady | Service ready for new user.
sfFtpClosingConnection | Service closing control connection.
sfFtpDataConnectionOpened | Data connection open, no transfer in progress.
sfFtpClosingDataConnection | Closing data connection, requested file action successful.
sfFtpEnteringPassiveMode | Entering passive mode.
sfFtpLoggedIn | User logged in, proceed. Logged out if appropriate.
sfFtpFileActionOk | Requested file action ok.
sfFtpDirectoryOk | PATHNAME created.
sfFtpNeedPassword | User name ok, need password.
sfFtpNeedAccountToLogIn | Need account for login.
sfFtpNeedInformation | Requested file action pending further information.
sfFtpServiceUnavailable | Service not available, closing control connection.
sfFtpDataConnectionUnavailable | Can't open data connection.
sfFtpTransferAborted | Connection closed, transfer aborted.
sfFtpFileActionAborted | Requested file action not taken.
sfFtpLocalError | Requested action aborted, local error in processing.
sfFtpInsufficientStorageSpace | Requested action not taken; insufficient storage space in system, file unavailable.
sfFtpCommandUnknown | Syntax error, command unrecognized.
sfFtpParametersUnknown | Syntax error in parameters or arguments.
sfFtpCommandNotImplemented | Command not implemented.
sfFtpBadCommandSequence | Bad sequence of commands.
sfFtpParameterNotImplemented | Command not implemented for that parameter.
sfFtpNotLoggedIn | Not logged in.
sfFtpNeedAccountToStore | Need account for storing files.
sfFtpFileUnavailable | Requested action not taken, file unavailable.
sfFtpPageTypeUnknown | Requested action aborted, page type unknown.
sfFtpNotEnoughMemory | Requested file action aborted, exceeded storage allocation.
sfFtpFilenameNotAllowed | Requested action not taken, file name not allowed.
sfFtpInvalidResponse | Response is not a valid FTP one.
sfFtpConnectionFailed | Connection with server failed.
sfFtpConnectionClosed | Connection with server closed.
sfFtpInvalidFile | Invalid file to upload / download.

Definition at line 53 of file Ftp.h.

enum sfFtpTransferMode

Enumeration of transfer modes.

Enumerator
sfFtpBinary | Binary mode (file is transfered as a sequence of bytes)
sfFtpAscii | Text mode using ASCII encoding.
sfFtpEbcdic | Text mode using EBCDIC encoding.

Definition at line 41 of file Ftp.h.

## Function Documentation

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtp* sfFtp_create | ( | void |  | ) |

Create a new Ftp object.

Returns
  A new sfFtp object

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API void sfFtp_destroy | ( | sfFtp * | ftp | ) |

Destroy a Ftp object.

Parameters

  ftp | Ftp object to destroy

CSFML_NETWORK_API sfFtpResponse* sfFtp_disconnect | ( | sfFtp * | ftp | ) |

Close the connection with the server.

Parameters

  ftp | Ftp object

Returns
  Server response to the request

CSFML_NETWORK_API sfFtpResponse* sfFtp_download | ( | sfFtp * | ftp,
|  | const char * | distantFile,
|  | const char * | destPath,
|  | 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpResponse* sfFtp_login | ( | sfFtp * | ftp,
|  | const char * | userName,
|  | 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpResponse* sfFtp_parentDirectory | ( | sfFtp * | ftp | ) |

Go to the parent directory of the current one.

Parameters

  ftp | Ftp object

Returns
  Server response to the request

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpResponse* sfFtp_upload | ( | sfFtp * | ftp,
|  | const char * | localFile,
|  | const char * | destPath,
|  | sfFtpTransferMode | mode
| ) |  |

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

Returns
  Server response to the request

CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy | ( | sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |

Destroy a FTP directory response.

Parameters

  ftpDirectoryResponse | Ftp directory response to destroy

CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |

Get the directory returned in a FTP directory response.

Parameters

  ftpDirectoryResponse | Ftp directory response

Returns
  Directory name

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |

Get the status code of a FTP directory response.

Parameters

  ftpDirectoryResponse | Ftp directory response

Returns
  Status code

CSFML_NETWORK_API 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

CSFML_NETWORK_API void sfFtpListingResponse_destroy | ( | sfFtpListingResponse * | ftpListingResponse | ) |

Destroy a FTP listing response.

Parameters

  ftpListingResponse | Ftp listing response to destroy

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus | ( | const sfFtpListingResponse * | ftpListingResponse | ) |

Get the status code of a FTP listing response.

Parameters

  ftpListingResponse | Ftp listing response

Returns
  Status code

CSFML_NETWORK_API 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

CSFML_NETWORK_API void sfFtpResponse_destroy | ( | sfFtpResponse * | ftpResponse | ) |

Destroy a FTP response.

Parameters

  ftpResponse | Ftp response to destroy

CSFML_NETWORK_API 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

CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus | ( | const sfFtpResponse * | ftpResponse | ) |

Get the status code of a FTP response.

Parameters

  ftpResponse | Ftp response object

Returns
  Status code

CSFML_NETWORK_API 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