mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-21 10:04:18 +00:00
15fb7891cb
Previously it removed one entry from m_aTimestamps before having filled it entirely, so there was a small chance that it was not the smallest one. Only after we have filled more entries than we want to keep can we know which ones can be deleted for sure.
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/* (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
|
|
|
|
class CFileCollection
|
|
{
|
|
enum
|
|
{
|
|
MAX_ENTRIES=1001,
|
|
TIMESTAMP_LENGTH=20, // _YYYY-MM-DD_HH-MM-SS
|
|
};
|
|
|
|
int64 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[512];
|
|
IStorage *m_pStorage;
|
|
int64 m_Remove; // Timestamp we want to remove
|
|
|
|
bool IsFilenameValid(const char *pFilename);
|
|
int64 ExtractTimestamp(const char *pTimestring);
|
|
void BuildTimestring(int64 Timestamp, char *pTimestring);
|
|
int64 GetTimestamp(const char *pFilename);
|
|
|
|
public:
|
|
void Init(IStorage *pStorage, const char *pPath, const char *pFileDesc, const char *pFileExt, int MaxEntries);
|
|
void AddEntry(int64 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
|