From: Georg Baum Date: Fri, 1 Dec 2006 20:09:08 +0000 (+0000) Subject: more unicode filenames X-Git-Tag: 1.6.10~11689 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5afcd541fd47b802fd8abfb52b7e933a2f955c7b;p=features.git more unicode filenames git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16127 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LaTeX.C b/src/LaTeX.C index d320b72d99..f77b22489d 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -523,16 +523,16 @@ void LaTeX::updateBibtexDependencies(DepTable & dep, it != bibtex_info.end(); ++it) { for (set::const_iterator it2 = it->databases.begin(); it2 != it->databases.end(); ++it2) { - string file = findtexfile(*it2, "bib"); + FileName const file = findtexfile(*it2, "bib"); if (!file.empty()) - dep.insert(FileName(makeAbsPath(file)), true); + dep.insert(file, true); } for (set::const_iterator it2 = it->styles.begin(); it2 != it->styles.end(); ++it2) { - string file = findtexfile(*it2, "bst"); + FileName const file = findtexfile(*it2, "bst"); if (!file.empty()) - dep.insert(FileName(makeAbsPath(file)), true); + dep.insert(file, true); } } } diff --git a/src/buffer.C b/src/buffer.C index 75a5010d5c..cdba1af4ce 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1274,7 +1274,7 @@ void Buffer::updateBibfilesCache() if (it->lyxCode() == InsetBase::BIBTEX_CODE) { InsetBibtex const & inset = dynamic_cast(*it); - vector const bibfiles = inset.getFiles(*this); + vector const bibfiles = inset.getFiles(*this); bibfilesCache_.insert(bibfilesCache_.end(), bibfiles.begin(), bibfiles.end()); @@ -1282,7 +1282,7 @@ void Buffer::updateBibfilesCache() InsetInclude & inset = dynamic_cast(*it); inset.updateBibfilesCache(*this); - vector const & bibfiles = + vector const & bibfiles = inset.getBibfilesCache(*this); bibfilesCache_.insert(bibfilesCache_.end(), bibfiles.begin(), @@ -1292,7 +1292,7 @@ void Buffer::updateBibfilesCache() } -vector const & Buffer::getBibfilesCache() const +vector const & Buffer::getBibfilesCache() const { // if this is a child document and the parent is already loaded // use the parent's cache instead diff --git a/src/buffer.h b/src/buffer.h index c7e34a530e..6b6addc10b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -18,6 +18,7 @@ #include "dociterator.h" #include "ParagraphList_fwd.h" +#include "support/filename.h" #include "support/limited_stack.h" #include "support/types.h" #include "support/docstring.h" @@ -35,8 +36,6 @@ namespace lyx { -namespace support { class FileName; } - class BufferParams; class ErrorItem; class FuncRequest; @@ -262,7 +261,7 @@ public: void updateBibfilesCache(); /// Return the cache with all bibfiles in use (including bibfiles /// of loaded child documents). - std::vector const & getBibfilesCache() const; + std::vector const & getBibfilesCache() const; /// void getLabelList(std::vector &) const; @@ -384,7 +383,7 @@ private: StableDocIterator anchor_; /// A cache for the bibfiles (including bibfiles of loaded child /// documents), needed for appropriate update of natbib labels. - std::vector bibfilesCache_; + std::vector bibfilesCache_; /// Container for all sort of Buffer dependant errors. std::map errorLists_; diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index a8e6905f3b..09ba80701a 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -305,18 +305,18 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os, } -vector const InsetBibtex::getFiles(Buffer const & buffer) const +vector const InsetBibtex::getFiles(Buffer const & buffer) const { Path p(buffer.filePath()); - vector vec; + vector vec; string tmp; // FIXME UNICODE string bibfiles = to_utf8(getParam("bibfiles")); bibfiles = split(bibfiles, tmp, ','); while (!tmp.empty()) { - string file = findtexfile(changeExtension(tmp, "bib"), "bib"); + FileName const file = findtexfile(changeExtension(tmp, "bib"), "bib"); lyxerr[Debug::LATEX] << "Bibfile: " << file << endl; // If we didn't find a matching file name just fail silently @@ -335,14 +335,14 @@ vector const InsetBibtex::getFiles(Buffer const & buffer) const void InsetBibtex::fillWithBibKeys(Buffer const & buffer, std::vector > & keys) const { - vector const files = getFiles(buffer); - for (vector::const_iterator it = files.begin(); + vector const files = getFiles(buffer); + for (vector::const_iterator it = files.begin(); it != files.end(); ++ it) { // This is a _very_ simple parser for Bibtex database // files. All it does is to look for lines starting // in @ and not being @preamble and @string entries. // It does NOT do any syntax checking! - ifstream ifs(it->c_str()); + ifstream ifs(it->toFilesystemEncoding().c_str()); string linebuf0; while (getline(ifs, linebuf0)) { string linebuf = trim(linebuf0); diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index c6ef73bb04..78f9e62dd4 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -16,6 +16,8 @@ #include #include "insetcommand.h" +#include "support/filename.h" + namespace lyx { @@ -39,7 +41,7 @@ public: void fillWithBibKeys(Buffer const & buffer, std::vector > & keys) const; /// - std::vector const getFiles(Buffer const &) const; + std::vector const getFiles(Buffer const &) const; /// bool addDatabase(std::string const &); /// diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index 5d66cef436..fcdbd0be88 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -35,6 +35,7 @@ namespace lyx { using support::ascii_lowercase; using support::contains; +using support::FileName; using support::getStringFromVector; using support::getVectorFromString; using support::ltrim; @@ -68,18 +69,18 @@ string const getNatbibLabel(Buffer const & buffer, static CachedMap cached_keys; // and cache the timestamp of the bibliography files. - static std::map bibfileStatus; + static std::map bibfileStatus; biblio::InfoMap infomap; - vector const & bibfilesCache = buffer.getBibfilesCache(); + vector const & bibfilesCache = buffer.getBibfilesCache(); // compare the cached timestamps with the actual ones. bool changed = false; - for (vector::const_iterator it = bibfilesCache.begin(); + for (vector::const_iterator it = bibfilesCache.begin(); it != bibfilesCache.end(); ++ it) { - string const f = *it; + FileName const f = *it; try { - std::time_t lastw = fs::last_write_time(f); + std::time_t lastw = fs::last_write_time(f.toFilesystemEncoding()); if (lastw != bibfileStatus[f]) { changed = true; bibfileStatus[f] = lastw; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index f374afcba3..2a55bf02c7 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -633,17 +633,17 @@ void InsetInclude::updateBibfilesCache(Buffer const & buffer) } -std::vector const & +std::vector const & InsetInclude::getBibfilesCache(Buffer const & buffer) const { Buffer * const tmp = getChildBuffer(buffer, params_); if (tmp) { tmp->setParentName(""); - std::vector const & cache = tmp->getBibfilesCache(); + std::vector const & cache = tmp->getBibfilesCache(); tmp->setParentName(parentFilename(buffer)); return cache; } - static std::vector const empty; + static std::vector const empty; return empty; } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 4610e0ea10..0b2cf43046 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -17,6 +17,8 @@ #include "render_button.h" #include "mailinset.h" +#include "support/filename.h" + #include namespace lyx { @@ -70,7 +72,7 @@ public: * Return an empty vector if the child doc is not loaded. * \param buffer the Buffer containing this inset. */ - std::vector const & + std::vector const & getBibfilesCache(Buffer const & buffer) const; /// EDITABLE editable() const { return IS_EDITABLE; } diff --git a/src/support/filetools.C b/src/support/filetools.C index b0401e71dd..825c508a36 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -1081,7 +1081,7 @@ cmd_ret const runCommand(string const & cmd) } -string const findtexfile(string const & fil, string const & /*format*/) +FileName const findtexfile(string const & fil, string const & /*format*/) { /* There is no problem to extend this function too use other methods to look for files. It could be setup to look @@ -1094,8 +1094,9 @@ string const findtexfile(string const & fil, string const & /*format*/) // If the file can be found directly, we just return a // absolute path version of it. - if (fs::exists(fil)) - return makeAbsPath(fil); + FileName const absfile(makeAbsPath(fil)); + if (fs::exists(absfile.toFilesystemEncoding())) + return absfile; // No we try to find it using kpsewhich. // It seems from the kpsewhich manual page that it is safe to use @@ -1125,9 +1126,9 @@ string const findtexfile(string const & fil, string const & /*format*/) << "kpse result = `" << rtrim(c.second, "\n") << '\'' << endl; if (c.first != -1) - return os::internal_path(rtrim(c.second, "\n\r")); + return FileName(os::internal_path(rtrim(c.second, "\n\r"))); else - return string(); + return FileName(); } diff --git a/src/support/filetools.h b/src/support/filetools.h index 3d2eb15bfe..d6bf08897c 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -263,7 +263,7 @@ bool readLink(std::string const & file, bool resolve = false); /// Uses kpsewhich to find tex files -std::string const findtexfile(std::string const & fil, +FileName const findtexfile(std::string const & fil, std::string const & format); /// remove the autosave-file and give a Message if it can't be done