Find the answer to your Linux question:
Results 1 to 2 of 2
Hi All, I want to sort the directory entries in a folder by access time. Does Linux provide a certain C API for this task ? There is readdir() function, ...
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    43

    Question C API to sort directory entries by access time

    Hi All,

    I want to sort the directory entries in a folder by access time.

    Does Linux provide a certain C API for this task ?

    There is readdir() function, however, as far as I see, it does not allow you to sort the file entries by access time.

    scandir() function also exists, however, I am not sure if it is capable of doing the job.

    Any help appreciated.

    Thanks.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You are getting there. The function scandir() will do what you want. You have to provide the sorting function where you would use stat() or fstat() to access the status information about each file to allow it to sort on the access time.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...