#ifndef CURLFTP_H #define CURLFTP_H #include "curl/curl.h" #include #include #include class CurlFtp { public: CurlFtp(); ~CurlFtp(); /* 列出FTP文件夹 */ static std::string listDir(const std::string &ftpUrl, const std::string &username, const std::string &password); /* 列出文件夹中的所有文件 */ static bool listFiles(const std::string &ftpUrl, const std::string &username, const std::string &password, std::vector& fileList); /* 检查文件夹是否存在 */ // static bool isDirExists(const std::string &ftpUrl, const std::string &username, const std::string &password); /* 使用正则表达式提取出文件夹 */ // static bool CurlFtp::extractDirectories(const std::string& responseString); /* 创建文件夹 */ static bool createDir(const std::string &ftpUrl, const std::string &username, const std::string &password, const std::string &dirName); /* 设置IP和端口 */ bool setFtpIPAndPort(const std::string& IP, const std::string& port); /* 设置用户名和密码 */ bool setFtpUsernameAndPassword(const std::string& username, const std::string& password); /* 列出文件列表 */ bool listAll(std::string dir, std::vector& fileList); private: std::mutex m_mutexCurl; /* curl互斥锁 */ CURL* m_curl = nullptr; /* curl句柄 */ CURLcode m_res = CURLE_OK; /* 返回值 */ std::string m_responseString; /* */ std::string m_IP; /* IP */ std::string m_port; /* 端口 */ std::string m_ftpUrl; /* ftpUrl */ std::string m_username; std::string m_password; std::string m_dirName; }; #endif /* CURLFTP_H */