#include "tex_helpers.h"
#include "debug.h"
+#include "gettext.h"
+
+#include "frontends/Alert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxalgo.h"
+#include "support/os.h"
#include "support/package.h"
#include "support/path.h"
#include "support/systemcall.h"
namespace lyx {
+using support::bformat;
using support::contains;
+using support::FileName;
using support::getExtension;
using support::getFileContents;
using support::getVectorFromString;
namespace frontend {
-// build filelists of all availabe bst/cls/sty-files. done through
-// kpsewhich and an external script, saved in *Files.lst
void rescanTexStyles()
{
// Run rescan in user lyx directory
Path p(package().user_support());
+ FileName const command = libFileSearch("scripts", "TeXFiles.py");
Systemcall one;
- one.startscript(Systemcall::Wait,
- "python " +
- quoteName(libFileSearch("scripts", "TeXFiles.py")));
+ int const status = one.startscript(Systemcall::Wait,
+ lyx::support::os::python() + ' ' +
+ quoteName(command.toFilesystemEncoding()));
+ if (status == 0)
+ return;
+ // FIXME UNICODE
+ Alert::error(_("Could not update TeX information"),
+ bformat(_("The script `%s' failed."), lyx::from_utf8(command.absFilename())));
}
void getTexFileList(string const & filename, std::vector<string> & list)
{
list.clear();
- string const file = libFileSearch("", filename);
+ FileName const file = libFileSearch("", filename);
if (file.empty())
return;
string const getListOfOptions(string const & classname, string const & type)
{
- string const filename = getTexFileFromList(classname,type);
+ FileName const filename(getTexFileFromList(classname, type));
+ if (filename.empty())
+ return string();
string optionList = string();
- std::ifstream is(filename.c_str());
+ std::ifstream is(filename.toFilesystemEncoding().c_str());
while (is) {
string s;
is >> s;
lstfile = "bstFiles.lst";
else if (type == "bib")
lstfile = "bibFiles.lst";
- string const allClasses = getFileContents(libFileSearch(string(),
- lstfile));
+ FileName const abslstfile = libFileSearch(string(), lstfile);
+ if (abslstfile.empty()) {
+ lyxerr << "File `'" << lstfile << "' not found." << endl;
+ return string();
+ }
+ string const allClasses = getFileContents(abslstfile);
int entries = 0;
string classfile = token(allClasses, '\n', entries);
int count = 0;