Operating System - Linux
1827809 Members
2039 Online
109969 Solutions
New Discussion

listing file of date range in C

 
Henry Chua
Super Advisor

listing file of date range in C

Hi Guys

May I know what is the fastest way (function) i can use in C to list the files od a certain date range in a directory?

Best regards
Henry
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor

Re: listing file of date range in C

Use opendir() to open a directory then use readdir() to read each entry to get the pathnames and feed each pathname to stat(). You will then have the mtime or ctime that you can compare with the current time that you got from time(). Man opendir,readdir,stat, and time for details. Note: all the times will be in epoch seconds but there is no need to convert to localtime. All you need to do is divide each value by 86400 to get the number of days difference.
If it ain't broke, I can fix that.