ftp_download(STRING* url, STRING* path, STRING* username, STRING* password)
Downloads a file from a ftp server.
ftp_upload(STRING* url, STRING* path, STRING* username, STRING* password)
Uploads a file to a ftp server.
ftp_getdate(STRING* url, STRING* username, STRING* password)
Ascertains the timestamp and the file size of a file stored on a ftp server.
ftp_stop()
Stops the currently running ftp transfer.
ftp_size()
Returns the total file size of the current/last file in bytes (long variable).
ftp_sent()
Returns the amount of sent data of the current/last file in bytes (long variable).
ftp_timestamp()
Returns the timestamp of the current/last file, after ftp_getdate() was executed successfully (long variable).
ftp_status()
Returns the status of a currently running or the last ftp transfer:
-1 if the last ftp transfer was stopped because of an error
0 if the ftp transfer is still running
1 if the last ftp transfer was successful
ftp_debug(var mode)
Enables/disables the logging of ftp transfers. The logfile is named "ftp_log.txt".
Parameters:
url - URL of the file to be downloaded, or destination URL for a file upload (e.g.: "ftp://www.testhoster.com/downloads/test.txt"), STRING* or char*
path - local path + filename (e.g.: "testdir/test.txt"), STRING* or char*
username - ftp username, STRING* or char*
password - ftp password, STRING* or char*
mode - 1 to enable, 0 to disable ftp logging
Remarks:
- The functions ftp_download(), ftp_upload(), ftp_getdate() and ftp_debug() return -1 if an error occured or 1 if everything went ok.
- After calling ftp_download(), ftp_upload() or ftp_getdate() you have to wait until the value of ftp_status() is nonzero.
- Only one ftp transfer can be run at the same time.
- The plugin acknet.dll must be loaded and the file acknet.h must be included for using the ftp functions.
Version:
P LC
Example:
#include <acknex.h>
#include <default.c>
#include <acknet.h>
long fsize;
long fsent;
long ftimestamp;
void get_levelfile()
{
//Downloads the file "level1.wmb" and saves it as "map1.wmb" in the "maps" dir:
ftp_download("ftp://www.testhost.com/levels/level1.wmb","maps/map1.wmb","username","password");
while (!ftp_status()) //as long as the download is running
{ //get informations about the download:
fsize = ftp_size();
fsent = ftp_sent();
wait(1);
}
if (ftp_status() == 1)
printf("Download successful!");
else
printf("Error during download!");
}
var get_dateANDsize(long* filesize, long* timestamp)
{
ftp_getdate("ftp://www.testhost.com/file.txt","username","password");
while (!ftp_status()) wait(1);//as long as the download is running
if (ftp_status() == 1)
{ //if the transfer was successfull, get the size and timestamp
*filesize = ftp_size();
*timestamp = ftp_timestamp();
if (*filesize == -1 || *timestamp == -1)
return -1; //if the timestamp or the size wheren't sent by the server
else
return 1;
}
else return -1;
}
See also:
http
► latest version online