CurlFtpInfo.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef CURLFTPINFO_H
  2. #define CURLFTPINFO_H
  3. #include <string>
  4. #include <regex>
  5. /* Std 异常处理的宏 */
  6. #define StdCatch \
  7. catch (const std::exception& e)\
  8. {\
  9. SPDLOG_WARN("Std std failed: {}", e.what());\
  10. return false;\
  11. }catch(...)\
  12. {\
  13. SPDLOG_WARN("Std Operated failed: unknown error");\
  14. return false;\
  15. }
  16. /* Std 异常处理的宏,不带返回值 */
  17. #define StdCatchNoReturn \
  18. catch (const std::exception& e)\
  19. {\
  20. SPDLOG_WARN("Std std failed: {}", e.what());\
  21. return;\
  22. }catch(...)\
  23. {\
  24. SPDLOG_WARN("Std Operated failed: unknown error");\
  25. return;\
  26. }
  27. /* 文件类型 */
  28. enum class CF_FileType
  29. {
  30. FILE,
  31. DIR,
  32. LINK,
  33. UNKNOWN
  34. };
  35. /* 上传下载类型 */
  36. enum class CF_TransType
  37. {
  38. UPLOAD = 0, /* 上传 */
  39. DOWNLOAD /* 下载 */
  40. };
  41. /* 文件信息 */
  42. struct CF_FileInfo
  43. {
  44. CF_FileType type; /* 文件类型 */
  45. uint64_t size; /* 文件大小 */
  46. std::string name; /* 文件名 */
  47. CF_FileInfo() : type(CF_FileType::UNKNOWN), size(0), name(""){}
  48. CF_FileInfo(CF_FileType type, uint64_t size, const std::string& name)
  49. : type(type), size(size), name(name) {}
  50. };
  51. /**
  52. * @brief 数组信息,上传下载时使用
  53. *
  54. */
  55. struct CF_ArrayInfo
  56. {
  57. uint64_t size = 0; /* 数组大小 */
  58. uint64_t pos = 0; /* 当前位置 */
  59. char* data = nullptr; /* 数据 */
  60. };
  61. #endif /* CURLFTPINFO_H */