Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-05-2012, 07:22 PM   #1
LQ Newbie
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
Checking Directory for New File / Recently Added in C 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?
Old 12-06-2012, 05:59 PM   #2
Senior Member
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
I see you've marked this "SOLVED" (presumably you discovered the inotify API in glibc), so I'll just make a token reply to take this topic off of the zero-reply list.


directories, stat

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find a file which is being written recently in directory of 1000 files? manalisharmabe Linux - Newbie 9 05-13-2012 07:47 PM
[SOLVED] How do we know if some files and folders were added to a directory recently garima721 Linux - General 3 02-13-2012 05:31 AM
[SOLVED] tar.gz: Cannot stat: No such file or directory windstory Linux - Newbie 2 09-07-2011 09:40 AM
cannot stat /etc/X11/X (no such file or directory) theabyyss Linux - Software 2 02-12-2008 08:15 PM
lsattr: no such file or directory while trying to stat... acampbell Linux - General 6 12-01-2003 03:41 PM

All times are GMT -5. The time now is 06:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration