]> git.lyx.org Git - features.git/commitdiff
Utility functions for converting preference files.
authorRichard Heck <rgheck@comcast.net>
Sun, 16 Jan 2011 19:51:02 +0000 (19:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Sun, 16 Jan 2011 19:51:02 +0000 (19:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37230 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/filetools.cpp
src/support/filetools.h

index 59090ecfaaabf3d70875a6c119c38aee8faaa156..bc100c090c777e8cd1371947b519930aab5fee02 100644 (file)
@@ -977,5 +977,32 @@ int compare_timestamps(FileName const & file1, FileName const & file2)
 }
 
 
+bool prefs2prefs(FileName const & filename, FileName const & tempfile, bool lfuns)
+{
+       FileName const script = libFileSearch("scripts", "prefs2prefs.py");
+       if (script.empty()) {
+               LYXERR0("Could not find bind file conversion "
+                               "script prefs2prefs.py.");
+               return false;
+       }
+
+       ostringstream command;
+       command << os::python() << ' ' << quoteName(script.toFilesystemEncoding())
+         << ' ' << (lfuns ? "-l" : "-p") << ' '
+               << quoteName(filename.toFilesystemEncoding())
+               << ' ' << quoteName(tempfile.toFilesystemEncoding());
+       string const command_str = command.str();
+
+       LYXERR(Debug::FILES, "Running `" << command_str << '\'');
+
+       cmd_ret const ret = runCommand(command_str);
+       if (ret.first != 0) {
+               LYXERR0("Could not run bind file conversion script prefs2prefs.py.");
+               return false;
+       }
+       return true;
+}
+
+
 } //namespace support
 } // namespace lyx
index 6bec3fb9dbf3417462b9882296a791a690343d29..49dadf9a33d617fe827b212afe6e7d62519e9195 100644 (file)
@@ -268,6 +268,10 @@ std::string const readBB_from_PSFile(FileName const & file);
  */
 int compare_timestamps(FileName const & file1, FileName const & file2);
 
+/// \param lfuns: true if we're converting lfuns, false if prefs
+bool prefs2prefs(FileName const & filename, FileName const & tempfile,
+                 bool lfuns);
+
 typedef std::pair<int, std::string> cmd_ret;
 
 cmd_ret const runCommand(std::string const & cmd);