summaryrefslogtreecommitdiff
path: root/replay/sv_fileservercleanup.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /replay/sv_fileservercleanup.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'replay/sv_fileservercleanup.h')
-rw-r--r--replay/sv_fileservercleanup.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/replay/sv_fileservercleanup.h b/replay/sv_fileservercleanup.h
new file mode 100644
index 0000000..65939e0
--- /dev/null
+++ b/replay/sv_fileservercleanup.h
@@ -0,0 +1,91 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=======================================================================================//
+
+#ifndef SV_FILESERVERCLEANUP_H
+#define SV_FILESERVERCLEANUP_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+//----------------------------------------------------------------------------------------
+
+#include "basethinker.h"
+#include "spew.h"
+#include "sv_basejob.h"
+
+//----------------------------------------------------------------------------------------
+
+bool SV_DoFileserverCleanup( bool bForceCleanAll, ISpewer *pSpewer/*=g_pDefaultSpewer*/ );
+CBaseJob *SV_CreateDeleteFileJob();
+
+//----------------------------------------------------------------------------------------
+
+class IFileserverCleanerJob
+{
+public:
+ virtual ~IFileserverCleanerJob() {}
+
+ virtual void AddFileForDelete( const char *pFilename ) = 0;
+ virtual int GetNumFilesDeleted() const = 0;
+};
+
+IFileserverCleanerJob *SV_CastJobToIFileserverCleanerJob( CBaseJob *pJob );
+
+//----------------------------------------------------------------------------------------
+
+class CFileserverCleaner : public CBaseThinker
+{
+public:
+ CFileserverCleaner();
+
+ void MarkFileForDelete( const char *pFilename );
+
+ int GetNumFilesDeleted() const { return m_nNumFilesDeleted; }
+ bool HasFilesQueuedForDelete() const { return m_pCleanerJob != NULL; }
+
+ void BlockForCompletion();
+ void DoCleanAsynchronous( bool bPrintResult = false, ISpewer *pSpewer = g_pDefaultSpewer );
+
+private:
+ void Clear();
+ void PrintResult();
+
+ virtual void Think();
+ virtual float GetNextThinkTime() const;
+
+ CBaseJob *m_pCleanerJob;
+ bool m_bRunning;
+ bool m_bPrintResult;
+ int m_nNumFilesDeleted;
+ ISpewer *m_pSpewer;
+};
+
+//----------------------------------------------------------------------------------------
+
+class CLocalFileDeleterJob : public CBaseJob,
+ public IFileserverCleanerJob
+{
+public:
+ CLocalFileDeleterJob();
+
+ virtual void AddFileForDelete( const char *pFilename );
+ virtual int GetNumFilesDeleted() const { return m_nNumDeleted; }
+
+ enum DeleteError_t
+ {
+ ERROR_FILE_DOES_NOT_EXIST,
+ };
+
+private:
+ virtual JobStatus_t DoExecute();
+
+ CUtlStringList m_vecFiles;
+ int m_nNumDeleted;
+};
+
+CLocalFileDeleterJob *SV_CreateLocalFileDeleterJob();
+
+//----------------------------------------------------------------------------------------
+
+#endif // SV_FILESERVERCLEANUP_H