ftp

Author: olfen, ahklerner, fincs Last Modified: 20090127


Set of functions to work with directories and files located on a FTP server.

FTP_Close()
FTP_CloseSocket(hConnect)
FTP_CreateDirectory(hConnect,DirName)
FTP_DeleteFile(hConnect,FileName)
FTP_FileTimeToStr(FileTime)
FTP_FindFirstFile(hConnect, SearchFile, ByRef @FindData)
FTP_FindNextFile(hEnum, ByRef @FindData)
FTP_GetCurrentDirectory(hConnect,ByRef DirName)
FTP_GetFile(hConnect,RemoteFile, NewFile="", Flags=0)
FTP_GetFileInfo(ByRef @FindData, InfoName)
FTP_GetFileSize(hConnect,FileName, Flags=0)
FTP_Open(Server, Port=21, Username=0, Password=0 ,Proxy="", ProxyBypass="")
FTP_PutFile(hConnect,LocalFile, NewRemoteFile="", Flags=0)
FTP_RemoveDirectory(hConnect,DirName)
FTP_RenameFile(hConnect,Existing, New)
FTP_SetCurrentDirectory(hConnect,DirName)

For more details of the functions's parameters and return value, please see it's source code.

Remarks

It is not strictly stdlib conform, because it uses in one or more functions global variables, at least in FTP_Open().

These functions are originally created and posted by olfen at http://www.autohotkey.com/forum/viewtopic.php?p=63704#63704.

Later ahklerner changed the source and republished at http://www.autohotkey.com/forum/viewtopic.php?p=170587#170587.

Some time later, fincs added a function FTP_GetCurrentDirectory() to the library. And now, I have added a prefix FTP_ to the function FileTimeToStr().

This is the result. Date is from last added function of fincs.

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?p=170587#170587

License

nonexistent

Example

; #Include ftp.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; General settings
server = www.autohotkey.net
port = 21
username = 0
password = 0

file_to_upload = %A_ScriptName%
file_remote_path = %A_ScriptName%

file_to_download = lib/path.ahk
file_local_path = path.ahk

; Start the processes
GoSub, Upload
GoSub, Download
Return

Upload:
hConnect:=FTP_Open(Server, Port, Username, Password)
FTP_PutFile(hConnect,file_to_upload, file_remote_path)
FTP_CloseSocket(hConnect)
FTP_Close()
MsgBox Upload completed.
Return

Download:
NewFile = path.ahk
RemoteFile = lib/path.ahk
hConnect:=FTP_Open(Server, Port, Username, Password)
FTP_GetFile(hConnect,file_to_download, file_local_path)
FTP_CloseSocket(hConnect)
FTP_Close()
MsgBox Download completed.
Return