Log file deletion?

S

subaruwrx88011

I am new to c++. Here is my problem. When my application runs it
creates a log file for that day containing application specific
information. The file format is CCSI_2006_51.log with 2006 being the
year and 51 being the days since Jan 1st. If we run this application
again on the same day it will append to the file already created
earlier. Though this application might not run everyday. So we could
have CCSI_2006_48.log and then CCSI_2006_51.log. I need to keep all log
files from 40 days ago to the present. There could be a total of 40 log
files if the application was indeed ran everyday for 40 day. Anything
created before 40 days ago has to be deleted.

Im think of the approach of a loop that checks the creation date of all
files ending in .log in a given directory and then deleting those that
have a date before presentDay minus 40. I have no idea how to do this
in c++ and my reference book doesn't have anything about this. I know
how to delete a file using the remove() method but how do I go through
every file ending in .log in a directory in c++ and how do I get the
creation date from the file into c++? Oh, the platform is linux.

Any help would be greatly appreciated.

Thanks in advance
 
V

Victor Bazarov

subaruwrx88011 said:
[..] I know
how to delete a file using the remove() method but how do I go through
every file ending in .log in a directory in c++ and how do I get the
creation date from the file into c++? Oh, the platform is linux.

There are no platform-independent ways [yet] in C++ to enumerate all files
whose name is of a particular pattern. You need to use platform-specific
means to do that. Since you use Linux, ask in comp.os.linux.development.*
newsgroups.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top