ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.6 KiB

  1. #ifndef CPPCMS_SESSION_POSIX_FILE_STORAGE_H
  2. #define CPPCMS_SESSION_POSIX_FILE_STORAGE_H
  3. #include "defs.h"
  4. #include "session_storage.h"
  5. #include "hold_ptr.h"
  6. #include <vector>
  7. namespace cppcms {
  8. namespace sessions {
  9. class session_file_storage_factory;
  10. class CPPCMS_API session_file_storage : public session_storage {
  11. public:
  12. session_file_storage(std::string path);
  13. virtual ~session_file_storage();
  14. virtual void save(std::string const &sid,time_t timeout,std::string const &in);
  15. virtual bool load(std::string const &sid,time_t &timeout,std::string &out);
  16. virtual void remove(std::string const &sid);
  17. private:
  18. struct locked_file;
  19. struct data;
  20. bool read_timestamp(void *h);
  21. bool read_from_file(void *h,time_t &timeout,std::string &data);
  22. void save_to_file(void *h,time_t timeout,std::string const &in);
  23. bool read_all(void *,void *vbuf,int n);
  24. bool write_all(void *,void const *vbuf,int n);
  25. void gc();
  26. std::string file_name(std::string const &sid);
  27. // members
  28. util::hold_ptr<data> d;
  29. std::string path_;
  30. // friends
  31. friend struct locked_file;
  32. friend class session_file_storage_factory;
  33. };
  34. class CPPCMS_API session_file_storage_factory : public session_storage_factory {
  35. public:
  36. session_file_storage_factory(std::string path);
  37. virtual intrusive_ptr<session_storage> get();
  38. virtual bool requires_gc();
  39. virtual void gc_job();
  40. virtual ~session_file_storage_factory();
  41. private:
  42. struct data;
  43. intrusive_ptr<session_file_storage> storage_;
  44. };
  45. } // sessions
  46. } // cppcms
  47. #endif