123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #include "mod_upload.h"
- #include "upload.h"
- #include "XZipZilb.h"
- #include "fileutil.h"
- //TEST_CASE_ENTITY_CLASS(CUploadEntity, "upload_create")
- //{
- // LOG_FUNCTION();
- //
- // struct list_head m_updir_list;//文件夹配置列表
- // INIT_LIST_HEAD(&m_updir_list);
- // CSimpleStringA checkStr = "";
- // CSmartPointer<IConfigInfo> spConfig;
- // this->GetFunction()->OpenConfig(Config_Software, spConfig);
- // ErrorCodeEnum Error = (ErrorCodeEnum)upload_create(&m_updir_list, this->GetFunction().GetRawPointer(), spConfig.GetRawPointer(), checkStr);
- // if (Error == Error_Succeed) {
- // Dbg("upload_create is success");
- // }
- // return Error;
- //}
- TEST_CASE_ENTITY_CLASS(CUploadEntity, "upload_fresh")
- {
- LOG_FUNCTION();
- struct list_head m_updir_list;//文件夹配置列表
- INIT_LIST_HEAD(&m_updir_list);
- CSimpleStringA checkStr = "";
- CSmartPointer<IConfigInfo> spConfig;
- this->GetFunction()->OpenConfig(Config_Software, spConfig);
- ErrorCodeEnum Error = (ErrorCodeEnum)upload_create(&m_updir_list, this->GetFunction().GetRawPointer(), spConfig.GetRawPointer(), checkStr);
- if (Error == Error_Succeed) {
- Dbg("upload_create is success");
- upload_fresh(&m_updir_list);
- }
- return Error;
- }
- #ifdef RVC_OS_WIN
- TEST_CASE_ENTITY_CLASS(CUploadEntity, "ZipData")
- {
- LOG_FUNCTION();
- string fileZipName = "c:\\testZip&650000000.zip";
- string destFile = "c:\\20201010.log";
- if (!ExistsFileA(destFile.c_str())) {
- FILE* f = fopen(destFile.c_str(), "wb");
- if (f != NULL) {
- string wStr = "test zip file";
- fwrite(wStr.c_str(), wStr.length(), 1, f);
- fclose(f);
- }
- else {
- Dbg("createFile fail");
- return Error_Exception;
- }
- }
-
- if (ZipData(fileZipName.c_str(), destFile.c_str())) {
- return Error_Succeed;
- }
- else {
- return Error_Exception;
- }
-
- }
- #else
- TEST_CASE_ENTITY_CLASS(CUploadEntity, "CreateZipFromFile")
- {
- LOG_FUNCTION();
- string fileZipName = "/opt/rvc/testZip&650000000.zip";
- string destFile = "/opt/rvc/20201010.log";
- if (!ExistsFileA(destFile.c_str())) {
- FILE* f = fopen(destFile.c_str(), "wb");
- if (f != NULL) {
- string wStr = "test zip file";
- fwrite(wStr.c_str(), wStr.length(), 1, f);
- fclose(f);
- }
- else {
- Dbg("createFile fail");
- return Error_Exception;
- }
- }
- if (CreateZipFromFile(destFile, fileZipName)) {
- return Error_Succeed;
- }
- else {
- return Error_Exception;
- }
- }
- #endif // RVC_OS_WIN
|