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.

33 lines
630 B

  1. #pragma once
  2. #include <SdFat.h>
  3. namespace sd {
  4. class RawSdFile {
  5. private:
  6. SdFat * _sd;
  7. const char *_filename;
  8. File _file;
  9. void open(const uint32_t pos);
  10. public:
  11. RawSdFile(SdFat *sd, const char *filename);
  12. ~RawSdFile();
  13. void flush();
  14. void write(const uint32_t pos, const void *val, const size_t size);
  15. template <typename T> void write(const uint32_t pos, const T &val)
  16. {
  17. write(pos, (void*)&val, sizeof(val));
  18. }
  19. void read(const uint32_t pos, void *val, const size_t size);
  20. template <typename T> void read(const uint32_t pos, const T &val)
  21. {
  22. read(pos, (void*)&val, sizeof(val));
  23. }
  24. };
  25. }