CSFML - C binding of the Simple and Fast Multimedia Library

CSFML 3.0.0
Loading...
Searching...
No Matches
Enumerations | Functions
Ftp.h File Reference
`#include <CSFML/Network/Export.h>`
`#include <CSFML/Network/IpAddress.h>`
`#include <CSFML/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
void | sfFtpListingResponse_destroy (const sfFtpListingResponse *ftpListingResponse)
| Destroy a FTP listing response.
bool | 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 (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Destroy a FTP directory response.
bool | 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.
const sfChar32 * | sfFtpDirectoryResponse_getDirectoryUnicode (const sfFtpDirectoryResponse *ftpDirectoryResponse)
| Get the directory returned in a FTP directory response.
void | sfFtpResponse_destroy (const sfFtpResponse *ftpResponse)
| Destroy a FTP response.
bool | 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 (const 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, bool 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.

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 54 of file Ftp.h.

## ◆ sfFtpTransferMode

enum sfFtpTransferMode

Enumeration of transfer modes.

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

Definition at line 42 of file Ftp.h.

## 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 | ( | const 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,
|  | bool | 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 true to append to or false to overwrite the remote file if it already exists

Returns
  Server response to the request

## ◆ sfFtpDirectoryResponse_destroy()

void sfFtpDirectoryResponse_destroy | ( | const 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.

The returned const char* owns the string and must be freed to avoid memory leaks.

Parameters

  ftpDirectoryResponse | Ftp directory response

Returns
  Directory name or NULL if it failed

## ◆ sfFtpDirectoryResponse_getDirectoryUnicode()

const sfChar32 * sfFtpDirectoryResponse_getDirectoryUnicode | ( | const sfFtpDirectoryResponse * | ftpDirectoryResponse | ) |

Get the directory returned in a FTP directory response.

The returned const sfChar32* owns the string and must be freed to avoid memory leaks.

Parameters

  ftpDirectoryResponse | Ftp directory response

Returns
  Directory name or NULL if it failed

## ◆ 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()

bool 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
  true if the status is a success, false if it is a failure

## ◆ sfFtpListingResponse_destroy()

void sfFtpListingResponse_destroy | ( | const 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() - 1]

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()

bool 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
  true if the status is a success, false if it is a failure

## ◆ sfFtpResponse_destroy()

void sfFtpResponse_destroy | ( | const 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()

bool 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
  true if the status is a success, false if it is a failure