954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to detect if a file has been modified from c++

hi

problem: I am extending a lua script engine. I would like the engine to be able to detect at runtime if a script has been modified and if so reload it. However I don't know how to detect if a file has been modified.

my idea: My idea was that whenever I run/load the script I use c++'s file handing functions to get a timestamp of when the file was last modified. This timestamp is then compared with the former timestamp (unless it is the first time) and saved as the new timestamp. However I have not been able to find any kind of support for such timestamps in my books or on the web.

Any help or pointer would be appriciated.

thanks in advance

jarrax
Newbie Poster
5 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

First things first: What Operating System are you using?

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

I am using Ubuntu 8.10.

jarrax
Newbie Poster
5 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

In that case use inotify . With inotify you can check in your program if changes have been made to a directory or file. No need for manual timestamp checking whatsoever! Example program is on page I linked to.

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You