You can also use this stock it will remove old folder content depending on the passed iTimeStamp...
for example this will remove all files EXCEPT the ones that were created an hour ago...
Code:
ExterminateFolderContent("myStupidFoler/", (get_systime() - (60 * 60)));
PHP Code:
stock ExterminateFolderContent(const szFolder[]="myStupidFoler/", iTimeStamp=0)
{
if(iTimeStamp <= 0) iTimeStamp = get_systime();
new iDir, szFile[ 32 ] , szFullFile[ 128 ], iDeleted;
if ( ( iDir = open_dir( szFolder , szFile , charsmax( szFile ) ) ) )
{
do
{
formatex( szFullFile , charsmax( szFullFile ) , "%s%s" , szFolder , szFile );
if ( GetFileTime(szFullFile, FileTime_Created) < iTimeStamp )
{
if( delete_file( szFullFile ) == 1 )
iDeleted++;
}
}
while ( next_file( iDir , szFile , charsmax( szFile ) ) )
close_dir( iDir );
return iDeleted;
}
else
{
log_error( AMX_ERR_NOTFOUND, "Directory's not found: %s" , szFolder );
return -1;
}
return 0;
}
__________________