2024-12-03 10:36:06 +08:00
|
|
|
#ifndef _ISS_FTP2MINIO_PROCESS_H_
|
|
|
|
#define _ISS_FTP2MINIO_PROCESS_H_
|
2024-11-15 16:12:14 +08:00
|
|
|
|
|
|
|
#include "process.h"
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2024-12-10 10:14:40 +08:00
|
|
|
#include <optional>
|
2024-11-15 16:12:14 +08:00
|
|
|
#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;
|
2024-12-10 10:14:40 +08:00
|
|
|
std::vector<std::string> m_listPaths; //需要查询的目录,用";"隔开
|
2024-11-15 16:12:14 +08:00
|
|
|
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);
|
|
|
|
|
2024-12-10 10:14:40 +08:00
|
|
|
std::string replaceChar(const std::string& str, char oldChar, char newChar) {
|
|
|
|
std::string result = str; // 复制原始字符串以避免修改原始数据
|
|
|
|
for (size_t i = 0; i < result.size(); ++i) {
|
|
|
|
if (result[i] == oldChar) {
|
|
|
|
result[i] = newChar; // 替换字符
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
std::optional<std::string> extractDate(const std::string& filename, const std::string& regex);
|
|
|
|
BOOLEAN push2minio(std::string, std::string);
|
2024-11-15 16:12:14 +08:00
|
|
|
};
|
|
|
|
|
2024-12-03 10:36:06 +08:00
|
|
|
#endif //_ISS_FTP2MINIO_PROCESS_H_
|