Thread: Checking Linux Directory for New File / Recently Added File using stat()

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    1

    Checking Linux Directory for New File / Recently Added File using stat()

    I am coding in C on RHEL 5.6 and trying to execute a function only when a new file has been added to a known directory.
    I am currently using stat(directory, &buffer); and comparing the modification time 'buffer.st_mtime' with a saved value.
    This activates on both addition and removal of files but I only care about addition.
    Does anyone know of an approach to check only if a file has been added to a directory?
    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Batch file checking current directory name
    By nvoigt in forum Tech Board
    Replies: 1
    Last Post: 07-06-2012, 05:44 AM
  2. stat() -> how to find out if file has S_IROTH
    By flegmik in forum C Programming
    Replies: 9
    Last Post: 12-09-2011, 05:59 AM
  3. know the only file name in a directory(Linux)
    By kapil1089thekin in forum C Programming
    Replies: 5
    Last Post: 10-15-2010, 08:56 AM
  4. help with my mIRC log file stat generator.
    By TravisS in forum C Programming
    Replies: 3
    Last Post: 06-13-2002, 09:28 PM
  5. Capturing file stat information
    By Sue Paterniti in forum C Programming
    Replies: 3
    Last Post: 04-15-2002, 05:47 AM

Tags for this Thread