fileManager.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _FILEMANAGER_H_
  2. #define _FILEMANAGER_H_
  3. #include<sys/types.h>
  4. #include<list>
  5. #include<string>
  6. #include"definations.h"
  7. #include<cstdio>
  8. #include<cstring>
  9. using std::list;
  10. using std::string;
  11. extern const char *(filetype_str[]);
  12. class recvfile_t{
  13. public:
  14. unsigned tarIp;
  15. unsigned fileno;
  16. string filename;
  17. unsigned filesize;
  18. unsigned filetype;
  19. unsigned time;
  20. unsigned attr;
  21. };
  22. class sendfile_t{
  23. public:
  24. unsigned tarIp;
  25. unsigned fileno;
  26. string filename;
  27. unsigned filesize;
  28. string filelocate;
  29. unsigned filetype;
  30. };
  31. class FileManager{
  32. private:
  33. FileManager()=default;
  34. static FileManager* instance;
  35. list<recvfile_t> recvls;
  36. list<sendfile_t> sendls;
  37. public:
  38. static FileManager* getInstance();
  39. int Addrecv(recvfile_t& tar);
  40. int Delrecv(unsigned tarno,unsigned tarIp);
  41. int Findrecv(unsigned tarno,unsigned tarIp,recvfile_t& tar);
  42. int GetrecvCopy(list<recvfile_t>& src);
  43. int Addsend(sendfile_t& tar);
  44. int Delsend(unsigned tarno,unsigned tarIp);
  45. int Findsend(unsigned tarno,unsigned tarIp,sendfile_t& tar);
  46. int GetsendCopy(list<sendfile_t>& src);
  47. };
  48. #endif