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

First things first: What Operating System are you using?

I am using Ubuntu 8.10.

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.