Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
- AuthorPosts
- Chandra3993Participant
Straight way you can not check the file is read or not.
For specific number of days or epoch seconds you can checkHere I have written the program for checking file is read in last 2 days
12345678910111213141516171819202122232425262728293031<br />#include <br />#include <br />#include <br />#include<br />#include<br /><br />main()<br />{<br />struct stat but ;<br />// Here you need to give the file name with absolute path.<br />stat("/home/pavunkumar/secrect",&but );<br />// Here I have calculated the one day epoch time.<br />int limit = 24*60*60;<br />// Getting the last read time of the file.<br />int read = but.st_atime ;<br />int current ;<br />// Getting the current epoch time.<br />current=time ( NULL ) ;<br />// Check file is not open for 2 days.<br />if (((current-read)/limit) >= 2 )<br />{<br />printf ( "file is not read ");<br />}<br />else<br />{<br />printf ( "file is read " ) ;<br />}<br />}<br /><br />Chandra3993ParticipantYou use can sleep function for prompting to require amount of time.
In condition you add the sleep(10).
It will wait for 10 seconds, then do the require stuffs
- AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)