Back to the WFC main page

wfc_delete_oldest_file

$Revision: 3 $

Declaration

BOOL wfc_delete_oldest_file( const CString& directory_name )

Description

This exciting revolutionary concept in computing . . . OK, this is a boring function. All it does is search a directory for the oldest file and deletes it. I use it to clear out log file directories when I need room. A file's age is computed using the time the file was last written to. This function will return TRUE if a file was deleted or FALSE if no file was deleted.

Example

void make_some_room( const CString& log_directory )
{
   WFCTRACEINIT( TEXT( "make_some_room()" ) );

   double percent_used = 0.0;
   
   percent_used = wfc_get_directory_usage_percentage( log_directory );

   while( percent_used >= 85.0 )
   {
      wfc_delete_oldest_file( log_directory );
      percent_used = wfc_get_directory_usage_percentage( log_directory );
   }
}

API's Used

wfc_delete_oldest_file() uses the following API's:
Copyright, 2000, Samuel R. Blackburn
$Workfile: wfc_delete_oldest_file.cpp $
$Modtime: 1/17/00 9:33a $