LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-05-2012, 07:22 PM   #1
co2calpoly
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?
Thanks.
 
Old 12-06-2012, 05:59 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,602

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.
 
  


Reply

Tags
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 08:54 PM.

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