LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 06: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, 04:59 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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



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
[SOLVED] tar.gz: Cannot stat: No such file or directory windstory Linux - Newbie 3 04-14-2020 04:08 AM
How to find a file which is being written recently in directory of 1000 files? manalisharmabe Linux - Newbie 9 05-13-2012 06: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 04:31 AM
cannot stat /etc/X11/X (no such file or directory) theabyyss Linux - Software 2 02-12-2008 07:15 PM
lsattr: no such file or directory while trying to stat... acampbell Linux - General 6 12-01-2003 02:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:12 AM.

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
Open Source Consulting | Domain Registration