filefunctions.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef FILEFUNCTIONS_H
  2. #define FILEFUNCTIONS_H
  3. #include <string>
  4. #include <ctime>
  5. #include <queue>
  6. namespace filefunctions
  7. {
  8. enum STATUS_CODE
  9. {
  10. SC_SUCCESS = 0,
  11. SC_INVALID_WD, // No or invalid working dir
  12. SC_INVALID_PATH,
  13. SC_DISK_FULL,
  14. SC_DOES_NOT_EXIST,
  15. SC_ALREADY_EXISTS,
  16. SC_READ_ONLY,
  17. SC_IS_DIRECTORY,
  18. SC_IS_NOT_DIRECTORY,
  19. SC_OTHER_FAILIURE
  20. // And so on
  21. };
  22. enum COMMAND_FLAGS
  23. {
  24. CF_NONE = 0,
  25. CF_FORCE = 1,
  26. CF_RELATIVE = 2
  27. };
  28. struct File_Struct
  29. {
  30. std::string path;
  31. unsigned int size;
  32. tm *modified = nullptr;
  33. tm *taken = nullptr;
  34. };
  35. extern std::string filefunctions_wd;
  36. STATUS_CODE cd (std::string const &path = "", COMMAND_FLAGS flags = CF_NONE);
  37. STATUS_CODE mv (std::string const &src, std::string const &dest, COMMAND_FLAGS flags = CF_NONE);
  38. STATUS_CODE mkdir (std::string const &path, COMMAND_FLAGS flags = CF_NONE);
  39. STATUS_CODE rm (std::string const &path, COMMAND_FLAGS flags = CF_NONE);
  40. std::string pwd (void);
  41. std::queue<File_Struct> ls (std::string path = filefunctions_wd);
  42. }
  43. #endif // FILEFUNCTIONS_H