Hi,
I am facing a problem, I am accessing a text file through my C program to fetch some values. The problem is that, i want to check whether the text file is updated before opening it, as i want to save the time of opening the file again if it is not updated from the last time....can anybody help....i came across fstat() API but that gives the size of file and i dont think i can rely on that....

Recommended Answers

All 4 Replies

Ok.... I am working on Red-Hat linux and want to achive my goal using C language....Is there a way through which i can get the last modification time of the text file through C language...??

In my knowledge there is no such inbuilt way in C language to get the last modified time.
The file doesn't hold such information even in Linux platforms.The file table has all such information but accessing it through just C language statements is doubtful.
May be you can include a module to write file access time at the beginning of the text file and always start access from a later point.

File Start:Access time____|Text of file-----------------------------------EOF

Always writing the file access time at the beginning of the file whenever the fopen() for the file is called.And then using fseek(<Some definite value>) and writing the file text from that point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.