/**
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#define DIRECTORY "demos" //Directory in which the demos are stored, relative to the tf directory. For the tf directory just put a "."
#define SECONDS 86400 //How old the demos can be before they are deleted, in seconds
#pragma semicolon 1
#include
#define PLUGIN_VERSION "0.1"
public Plugin:myinfo = {
name = "Demo Deletion",
author = "WakiMiko",
description = "Deletes demos that are older than X seconds from the server",
version = PLUGIN_VERSION,
url = "http://wakimiko.wwwchan.com"
}
public OnMapStart() {
new String:name[100];
new String:path[PLATFORM_MAX_PATH] = DIRECTORY;
new String:file[PLATFORM_MAX_PATH];
new Handle:dir = OpenDirectory(path);
new contains;
while(ReadDirEntry(dir, name, sizeof(name))) {
contains = StrContains(name, ".dem", true);
if(contains != -1 && contains == strlen(name) - 4) {
strcopy(file,255,path);
StrCat(file,255,"/");
StrCat(file, 255, name);
if(GetFileTime(file, FileTime_LastChange) <= GetTime() - SECONDS)
DeleteFile(file);
}
}
CloseHandle(dir);
}