| 49 | } |
| 50 | |
| 51 | class FileSystem { |
| 52 | public: |
| 53 | FileSystem() FL_NOEXCEPT; |
| 54 | bool beginSd(int cs_pin); // Signal to begin using the filesystem resource. |
| 55 | bool begin(FsImplPtr platform_filesystem); // Signal to begin using the |
| 56 | // filesystem resource. |
| 57 | void end(); // Signal to end use of the file system. |
| 58 | |
| 59 | fl::ifstream |
| 60 | openRead(const char *path); // Returns closed ifstream if file could not be opened. |
| 61 | Video |
| 62 | openVideo(const char *path, fl::size pixelsPerFrame, float fps = 30.0f, |
| 63 | fl::size nFrameHistory = 0); // Null if video could not be opened. |
| 64 | Video |
| 65 | openMpeg1Video(const char *path, fl::size pixelsPerFrame, float fps = 30.0f, |
| 66 | fl::size nFrameHistory = 0); // Open MPEG1 video file |
| 67 | bool readText(const char *path, string *out); |
| 68 | bool readJson(const char *path, json *doc); |
| 69 | bool readScreenMaps(const char *path, fl::flat_map<string, ScreenMap> *out, |
| 70 | string *error = nullptr); |
| 71 | bool readScreenMap(const char *path, const char *name, ScreenMap *out, |
| 72 | string *error = nullptr); |
| 73 | // Load JPEG image from file path directly to Frame |
| 74 | FramePtr loadJpeg(const char *path, const JpegConfig &config = JpegConfig(), |
| 75 | fl::string *error_message = nullptr); |
| 76 | |
| 77 | // Open MP3 audio file and return streaming decoder |
| 78 | fl::Mp3DecoderPtr openMp3(const char *path, |
| 79 | fl::string *error_message = nullptr); |
| 80 | |
| 81 | private: |
| 82 | FsImplPtr mFs; // System dependent filesystem. |
| 83 | }; |
| 84 | |
| 85 | // Platforms will subclass this to implement the filesystem. |
| 86 | class FsImpl { |