X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxtextclasslist.C;h=d9048a75be9dd4d603f7e6c7730c52729ce3d33e;hb=52eb91c94fb70d58dceef430659c8781de2eccda;hp=11e08c08831c316848d8782a691cb155c6cc49c1;hpb=d056d510879bbdff0e62a586bd55b466cb8887ad;p=lyx.git diff --git a/src/lyxtextclasslist.C b/src/lyxtextclasslist.C index 11e08c0883..d9048a75be 100644 --- a/src/lyxtextclasslist.C +++ b/src/lyxtextclasslist.C @@ -22,21 +22,20 @@ #include #include #include -namespace fs = boost::filesystem; -using lyx::textclass_type; -using lyx::support::libFileSearch; -using lyx::support::makeDisplayPath; +namespace lyx { +namespace fs = boost::filesystem; + +using support::FileName; +using support::addName; +using support::libFileSearch; +using support::makeDisplayPath; using boost::bind; using boost::regex; using boost::smatch; -#ifndef CXX_GLOBAL_CSTD -using std::exit; -#endif - using std::endl; using std::equal_to; using std::find_if; @@ -98,13 +97,14 @@ public: bool LyXTextClassList::read() { LyXLex lex(0, 0); - string real_file = libFileSearch("", "textclass.lst"); + support::FileName const real_file = libFileSearch("", "textclass.lst"); lyxerr[Debug::TCLASS] << "Reading textclasses from `" << real_file << '\'' << endl; if (real_file.empty()) { lyxerr << "LyXTextClassList::Read: unable to find " - "textclass file `" << makeDisplayPath(real_file, 1000) + "textclass file `" + << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) << "'. Exiting." << endl; return false; // This causes LyX to end... Not a desirable behaviour. Lgb @@ -122,7 +122,8 @@ bool LyXTextClassList::read() if (!lex.isOK()) { lyxerr << "LyXTextClassList::Read: unable to open " - "textclass file `" << makeDisplayPath(real_file, 1000) + "textclass file `" + << to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) << "'\nCheck your installation. LyX can't continue." << endl; return false; @@ -174,20 +175,20 @@ bool LyXTextClassList::read() } -std::pair const +std::pair const LyXTextClassList::addTextClass(std::string const & textclass, std::string const & path) { // only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS // NOTE: latex class name is defined in textclass.layout, which can be different from textclass - string layout_file = path + "/" + textclass + ".layout"; - if (fs::exists(layout_file)) { + FileName const layout_file(addName(path, textclass + ".layout")); + if (fs::exists(layout_file.toFilesystemEncoding())) { lyxerr[Debug::TCLASS] << "Adding class " << textclass << " from directory " << path << endl; // Read .layout file and get description, real latex classname etc // // This is a C++ version of function processLayoutFile in configure.py, // which uses the following regex // \Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)} - ifstream ifs(layout_file.c_str()); + ifstream ifs(layout_file.toFilesystemEncoding().c_str()); static regex const reg("^#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*" "(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*"); string line; @@ -230,3 +231,6 @@ bool LyXSetStyle() lyxerr[Debug::TCLASS] << "LyXSetStyle: configuration parsed." << endl; return true; } + + +} // namespace lyx