66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#ifndef _ZJD_FTP2MINIO_PROCESS_H_
|
|
#define _ZJD_FTP2MINIO_PROCESS_H_
|
|
|
|
#include "process.h"
|
|
#include <string>
|
|
#include <vector>
|
|
#include <curl/curl.h>
|
|
#include <unordered_map>
|
|
#include <miniocpp/client.h>
|
|
|
|
class FtpManage
|
|
{
|
|
public:
|
|
FtpManage();
|
|
FtpManage(const std::string user, const std::string password, const std::string id);
|
|
~FtpManage();
|
|
|
|
bool DownloadFile(const char* remoteFilePath, const char* localDirectory);
|
|
bool DownloadAllFiles(const char* remoteFilePath, const char* localDirectory);
|
|
const std::vector<std::string>& GetFilesName(const std::string filepath);
|
|
|
|
private:
|
|
void SetURL();
|
|
std::string UrlEncode(const std::string& value);
|
|
std::string GetFileNameFromPath(const std::string& filePath);
|
|
bool GetfilenameFromftp(const std::string directoryname);
|
|
|
|
private:
|
|
std::string Ftp_ip; //Ftp服务器地址
|
|
std::string User, Password; //登录用户名及密码
|
|
std::string _URL;
|
|
std::vector<std::string> fNs; //用于记录全部文件名
|
|
CURL* curl;
|
|
};
|
|
|
|
typedef std::unordered_map<std::string, int> fileName2Idmap;
|
|
|
|
class CFtp2MinioProcess : public CProcess
|
|
{
|
|
public:
|
|
CFtp2MinioProcess();
|
|
virtual ~CFtp2MinioProcess();
|
|
|
|
virtual BOOLEAN OnPreCreate(int id);
|
|
virtual BOOLEAN Run(void);
|
|
virtual BOOLEAN OnTimer(void);
|
|
|
|
private:
|
|
FtpManage* m_pAftp;
|
|
std::string m_listPath; //需要查询的目录
|
|
std::string m_localPath; //文件保存到本地的目录
|
|
|
|
//struNetWorkOption network;
|
|
struRYFTP2MINIOOption m_nOptions;
|
|
|
|
DWORD last_min;
|
|
fileName2Idmap fileName2Id_map;
|
|
DWORD last_count;
|
|
void saveMapToFile(void);
|
|
void loadMapFromFile(void);
|
|
|
|
BOOLEAN push2minio(std::string);
|
|
};
|
|
|
|
#endif //_ZJD_FTP2MINIO_PROCESS_H_
|