Author: rgheck
Date: Sun Jan 16 20:51:02 2011
New Revision: 37230
URL: http://www.lyx.org/trac/changeset/37230
Log:
Utility functions for converting preference files.
Modified:
lyx-devel/trunk/src/support/filetools.cpp
lyx-devel/trunk/src/support/filetools.h
Modified: lyx-devel/trunk/src/support/filetools.cpp
==============================================================================
--- lyx-devel/trunk/src/support/filetools.cpp Sun Jan 16 20:14:14 2011
(r37229)
+++ lyx-devel/trunk/src/support/filetools.cpp Sun Jan 16 20:51:02 2011
(r37230)
@@ -977,5 +977,32 @@
}
+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
Modified: lyx-devel/trunk/src/support/filetools.h
==============================================================================
--- lyx-devel/trunk/src/support/filetools.h Sun Jan 16 20:14:14 2011
(r37229)
+++ lyx-devel/trunk/src/support/filetools.h Sun Jan 16 20:51:02 2011
(r37230)
@@ -268,6 +268,10 @@
*/
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);