ddnet/src/engine/shared/filecollection.h

43 lines
1.2 KiB
C
Raw Normal View History

/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef ENGINE_SHARED_FILECOLLECTION_H
#define ENGINE_SHARED_FILECOLLECTION_H
#include <engine/storage.h>
#include <stddef.h>
class CFileCollection
{
enum
{
MAX_ENTRIES = 1001,
TIMESTAMP_LENGTH = 20, // _YYYY-MM-DD_HH-MM-SS
};
2021-06-23 05:05:49 +00:00
int64_t m_aTimestamps[MAX_ENTRIES];
int m_NumTimestamps;
int m_MaxEntries;
char m_aFileDesc[128];
int m_FileDescLength;
char m_aFileExt[32];
int m_FileExtLength;
char m_aPath[IO_MAX_PATH_LENGTH];
IStorage *m_pStorage;
2021-06-23 05:05:49 +00:00
int64_t m_Remove; // Timestamp we want to remove
bool IsFilenameValid(const char *pFilename);
2021-06-23 05:05:49 +00:00
int64_t ExtractTimestamp(const char *pTimestring);
void BuildTimestring(int64_t Timestamp, char *pTimestring);
int64_t GetTimestamp(const char *pFilename);
public:
void Init(IStorage *pStorage, const char *pPath, const char *pFileDesc, const char *pFileExt, int MaxEntries);
2021-06-23 05:05:49 +00:00
void AddEntry(int64_t Timestamp);
static int FilelistCallback(const char *pFilename, int IsDir, int StorageType, void *pUser);
static int RemoveCallback(const char *pFilename, int IsDir, int StorageType, void *pUser);
};
#endif