]> git.lyx.org Git - features.git/blobdiff - src/support/filetools.cpp
tex2lyx: Run configure.py if needed (bug #8539)
[features.git] / src / support / filetools.cpp
index 040272aade620e406bed47dcca8947126c0c763d..7691fe3b321cb1e3bf32b7516bc97f02584662aa 100644 (file)
@@ -745,7 +745,7 @@ string const replaceCurdirPath(string const & path, string const & pathlist)
                }
                if (i != string::npos) {
                        newpathlist += sep;
-                       // Stop here if the last element is empty 
+                       // Stop here if the last element is empty
                        if (++i == oldpathlist.length())
                                break;
                }
@@ -1172,6 +1172,27 @@ bool prefs2prefs(FileName const & filename, FileName const & tempfile, bool lfun
        return true;
 }
 
+
+bool configFileNeedsUpdate(string const & file)
+{
+       // We cannot initialize configure_script directly because the package
+       // is not initialized yet when static objects are constructed.
+       static FileName configure_script;
+       static bool firstrun = true;
+       if (firstrun) {
+               configure_script =
+                       FileName(addName(package().system_support().absFileName(),
+                               "configure.py"));
+               firstrun = false;
+       }
+
+       FileName absfile =
+               FileName(addName(package().user_support().absFileName(), file));
+       return !absfile.exists()
+               || configure_script.lastModified() > absfile.lastModified();
+}
+
+
 int fileLock(const char * lock_file)
 {
        int fd = -1;