2011-07-22 21:17:16 +00:00
|
|
|
/* (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
|
|
|
|
|
2022-06-16 15:06:15 +00:00
|
|
|
#include <base/system.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
|
2022-05-29 12:03:16 +00:00
|
|
|
#include <stdint.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
|
2022-06-16 15:06:15 +00:00
|
|
|
class IStorage;
|
|
|
|
|
2011-07-22 21:17:16 +00:00
|
|
|
class CFileCollection
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
MAX_ENTRIES = 1001,
|
|
|
|
TIMESTAMP_LENGTH = 20, // _YYYY-MM-DD_HH-MM-SS
|
2011-07-22 21:17:16 +00:00
|
|
|
};
|
|
|
|
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_aTimestamps[MAX_ENTRIES];
|
2011-07-22 21:17:16 +00:00
|
|
|
int m_NumTimestamps;
|
|
|
|
int m_MaxEntries;
|
|
|
|
char m_aFileDesc[128];
|
|
|
|
int m_FileDescLength;
|
|
|
|
char m_aFileExt[32];
|
|
|
|
int m_FileExtLength;
|
2021-09-13 08:06:34 +00:00
|
|
|
char m_aPath[IO_MAX_PATH_LENGTH];
|
2011-07-22 21:17:16 +00:00
|
|
|
IStorage *m_pStorage;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_Remove; // Timestamp we want to remove
|
2011-07-22 21:17:16 +00:00
|
|
|
|
|
|
|
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);
|
2011-07-22 21:17:16 +00:00
|
|
|
|
|
|
|
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);
|
2011-07-22 21:17:16 +00:00
|
|
|
|
|
|
|
static int FilelistCallback(const char *pFilename, int IsDir, int StorageType, void *pUser);
|
2015-08-22 15:21:00 +00:00
|
|
|
static int RemoveCallback(const char *pFilename, int IsDir, int StorageType, void *pUser);
|
2011-07-22 21:17:16 +00:00
|
|
|
};
|
|
|
|
|
2011-07-30 16:29:40 +00:00
|
|
|
#endif
|