檢視原始碼 ct_ftp (common_test v1.27.5)
FTP 客戶端模組(基於 ftp
應用程式)。
摘要
函式
變更遠端主機上的目錄。
關閉 FTP 連線。
刪除遠端主機上的檔案。
開啟 FTP 連線並從遠端主機取得檔案。
列出目錄 Dir
。
開啟與指定節點的 FTP 連線。
開啟 FTP 連線並將檔案傳送到遠端主機。
透過 FTP 取得檔案。
透過 FTP 取得檔案。
透過 FTP 傳送檔案。
透過 FTP 傳送檔案。
變更檔案傳輸類型。
類型
函式
-spec cd(Connection, Dir) -> ok | {error, Reason} when Connection :: connection(), Dir :: file:filename(), Reason :: term().
變更遠端主機上的目錄。
-spec close(Connection) -> ok | {error, Reason} when Connection :: connection(), Reason :: term().
關閉 FTP 連線。
-spec delete(Connection, File) -> ok | {error, Reason} when Connection :: connection(), File :: file:filename(), Reason :: term().
刪除遠端主機上的檔案。
-spec get(KeyOrName, RemoteFile, LocalFile) -> ok | {error, Reason} when KeyOrName :: ct:key_or_name(), RemoteFile :: file:filename(), LocalFile :: file:filename(), Reason :: term().
開啟 FTP 連線並從遠端主機取得檔案。
RemoteFile
和 LocalFile
必須是絕對路徑。
設定檔必須與 ct_ftp:put/3
的設定檔相同。
另請參閱 ct:require/2
。
-spec ls(Connection, Dir) -> {ok, Listing} | {error, Reason} when Connection :: connection(), Dir :: file:filename(), Listing :: string(), Reason :: term().
列出目錄 Dir
。
-spec open(KeyOrName) -> {ok, Handle} | {error, Reason} when KeyOrName :: ct:key_or_name(), Handle :: handle(), Reason :: term().
開啟與指定節點的 FTP 連線。
您可以針對特定的 Name
開啟連線,並將相同的名稱用作所有後續操作的參考。如果您希望連線與 Handle
相關聯(例如,您需要開啟多個與主機的連線),請使用 Key
,即組態變數名稱,來指定目標。沒有關聯目標名稱的連線只能使用控制代碼值關閉。
有關如何建立新的 Name
的資訊,請參閱 ct:require/2
。
-spec put(KeyOrName, LocalFile, RemoteFile) -> ok | {error, Reason} when KeyOrName :: ct:key_or_name(), LocalFile :: file:filename(), RemoteFile :: file:filename(), Reason :: term().
開啟 FTP 連線並將檔案傳送到遠端主機。
LocalFile
和 RemoteFile
必須是絕對路徑。
如果目標主機是「特殊」節點,則 FTP 位址必須在設定檔中指定如下
{node,[{ftp,IpAddr}]}.
如果目標主機是其他主機,例如 UNIX 主機,則設定檔也必須包含使用者名稱和密碼(均為字串)
{unix,[{ftp,IpAddr},
{username,Username},
{password,Password}]}.
另請參閱 ct:require/2
。
-spec recv(Connection, RemoteFile) -> ok | {error, Reason} when Connection :: connection(), RemoteFile :: file:filename(), Reason :: term().
透過 FTP 取得檔案。
該檔案在本地主機上會取得相同的名稱。
另請參閱 ct_ftp:recv/3
。
-spec recv(Connection, RemoteFile, LocalFile) -> ok | {error, Reason} when Connection :: connection(), RemoteFile :: file:filename(), LocalFile :: file:filename(), Reason :: term().
透過 FTP 取得檔案。
該檔案在本地主機上命名為 LocalFile
。
-spec send(Connection, LocalFile) -> ok | {error, Reason} when Connection :: connection(), LocalFile :: file:filename(), Reason :: term().
透過 FTP 傳送檔案。
該檔案在遠端主機上會取得相同的名稱。
另請參閱 ct_ftp:send/3
。
-spec send(Connection, LocalFile, RemoteFile) -> ok | {error, Reason} when Connection :: connection(), LocalFile :: file:filename(), RemoteFile :: file:filename(), Reason :: term().
透過 FTP 傳送檔案。
該檔案在遠端主機上命名為 RemoteFile
。
-spec type(Connection, Type) -> ok | {error, Reason} when Connection :: connection(), Type :: ascii | binary, Reason :: term().
變更檔案傳輸類型。