| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef ENGINE_SHARED_FILECOLLECTION_H |
| 4 | #define ENGINE_SHARED_FILECOLLECTION_H |
| 5 | |
| 6 | #include <base/system.h> |
| 7 | #include <base/types.h> |
| 8 | |
| 9 | #include <cstdint> |
| 10 | #include <vector> |
| 11 | |
| 12 | class IStorage; |
| 13 | |
| 14 | class CFileCollection |
| 15 | { |
| 16 | enum |
| 17 | { |
| 18 | TIMESTAMP_LENGTH = 20, // _YYYY-MM-DD_HH-MM-SS |
| 19 | }; |
| 20 | |
| 21 | struct CFileEntry |
| 22 | { |
| 23 | time_t m_Timestamp; |
| 24 | char m_aFilename[IO_MAX_PATH_LENGTH]; |
| 25 | CFileEntry(int64_t Timestamp, const char *pFilename) |
| 26 | { |
| 27 | m_Timestamp = Timestamp; |
| 28 | str_copy(dst&: m_aFilename, src: pFilename); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | std::vector<CFileEntry> m_vFileEntries; |
| 33 | char m_aFileDesc[128]; |
| 34 | int m_FileDescLength; |
| 35 | char m_aFileExt[32]; |
| 36 | int m_FileExtLength; |
| 37 | char m_aPath[IO_MAX_PATH_LENGTH]; |
| 38 | IStorage *m_pStorage; |
| 39 | |
| 40 | bool (const char *pTimestring, time_t *pTimestamp); |
| 41 | bool ParseFilename(const char *pFilename, time_t *pTimestamp); |
| 42 | |
| 43 | public: |
| 44 | void Init(IStorage *pStorage, const char *pPath, const char *pFileDesc, const char *pFileExt, int MaxEntries); |
| 45 | |
| 46 | static int FilelistCallback(const char *pFilename, int IsDir, int StorageType, void *pUser); |
| 47 | }; |
| 48 | |
| 49 | #endif |
| 50 | |