From 0e2828917b0e1987462a26e732ffba784b9991f1 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sun, 16 Jan 2011 19:51:02 +0000 Subject: [PATCH] Utility functions for converting preference files. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37230 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/filetools.cpp | 27 +++++++++++++++++++++++++++ src/support/filetools.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index 59090ecfaa..bc100c090c 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -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 diff --git a/src/support/filetools.h b/src/support/filetools.h index 6bec3fb9db..49dadf9a33 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -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 cmd_ret; cmd_ret const runCommand(std::string const & cmd); -- 2.39.5