ubuntu下linux:curl使用ftp获取服务器上指定目录的所有文件集合以及下载

curl使用ftp获取服务器上指定目录的所有文件集合以及下载

直接编译可用,注意修改测试main函数内的字符串,注释我觉得写的挺详细了,跑不起来的评论区可问

头文件

#ifndef FTP_DOWNLOAD_H
#define FTP_DOWNLOAD_H
#include <iostream>
#include <functional>
#include <memory>
#include <vector>
#include<cstdlib>
#include <ctime>
using namespace std;
using OutPutList = vector<string>;
#define FTPBODY "ftp-list"

struct FtpFile
{
	string local;
	FILE *stream;
};

class FtpDownloadder
{
public:
       /**
        * @brief Construct a new Ftp Downloadder object
        * 
        * @param ip 
        * @param port 
        * @param username 
        * @param password 
        */
       FtpDownloadder(const char *ip,const char *port,const char *username,const char *password);
	~FtpDownloadder();

       /**
        * @brief 获取指定文件夹下所有文件名
        * 
        * @param folderName 指定文件夹名称
        *     (从登录用户家目录开始算,for example: /home/user/targetFolder  , you can give a param with "targetFolder")
        * @return OutPutList 该文件夹下的所有文件名集合,包含拓展名
        */
       OutPutList getAllItem(const string& folderName);
       /**
        * @brief  更新本地缓存
        * 
        * @param fileList ftp服务器上的文件集合
        * @param remotFolderPath ftp服务器上的文件夹路径
        *     (从登录用户家目录开始算,for example: /home/user/targetFolder  , you can give a param with "targetFolder")
        * @param localCacheFolder 本地缓存文件夹
        * @return true successful
        * @return false faild
        */
       bool flashLocalCache(const OutPutList& fileList, const string& remotFolderPath, const string& localCacheFolder);
       /**
        * @brief 下载文件
        * 
        * @param filePath ftp服务器上的文件路径
        *   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值