12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include "mod_upload.h"
- #include "upload.h"
- #include "XZipZilb.h"
- #include "fileutil.h"
- 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
|