in reply to How can I access a cross directory set of data files by most recently modified date?

Here's yet another WTDI:

This solution maintains a queue/array of size N (ie. store the names of the newest 5 files)

Linearly traverse the directory structure Compare timestamp of current file to timestamp of oldest/last item i +n queue If file is newer Seek (the sorted) insertion point in the queue, and insert via spl +ice If queue size > N pop off the oldest element from the queue Repeat until finished...

When finished, you'll have a sorted array containing the newest 5 files

Update: BTW, you'll need to save the appropriate stat info for each queue element


Where do you want *them* to go today?
  • Comment on Re: How can I access a cross directory set of data files by most recently modified date?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I access a cross directory set of data files by most recently modified date?
by shmem (Chancellor) on Jun 07, 2007 at 19:37 UTC