]> git.lyx.org Git - features.git/commitdiff
more unicode filenames
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 1 Dec 2006 20:09:08 +0000 (20:09 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 1 Dec 2006 20:09:08 +0000 (20:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16127 a592a061-630c-0410-9148-cb99ea01b6c8

src/LaTeX.C
src/buffer.C
src/buffer.h
src/insets/insetbibtex.C
src/insets/insetbibtex.h
src/insets/insetcite.C
src/insets/insetinclude.C
src/insets/insetinclude.h
src/support/filetools.C
src/support/filetools.h

index d320b72d99ee2a389beb4bea2f029dc5ec949da4..f77b22489dcdd37ca69052b80ef2608993b55488 100644 (file)
@@ -523,16 +523,16 @@ void LaTeX::updateBibtexDependencies(DepTable & dep,
             it != bibtex_info.end(); ++it) {
                for (set<string>::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<string>::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);
                }
        }
 }
index 75a5010d5cfb30d20e3fe2f97c14b3135df5dff0..cdba1af4ce6ed661ba5f6867fa4c582bc84602af 100644 (file)
@@ -1274,7 +1274,7 @@ void Buffer::updateBibfilesCache()
                if (it->lyxCode() == InsetBase::BIBTEX_CODE) {
                        InsetBibtex const & inset =
                                dynamic_cast<InsetBibtex const &>(*it);
-                       vector<string> const bibfiles = inset.getFiles(*this);
+                       vector<FileName> const bibfiles = inset.getFiles(*this);
                        bibfilesCache_.insert(bibfilesCache_.end(),
                                bibfiles.begin(),
                                bibfiles.end());
@@ -1282,7 +1282,7 @@ void Buffer::updateBibfilesCache()
                        InsetInclude & inset =
                                dynamic_cast<InsetInclude &>(*it);
                        inset.updateBibfilesCache(*this);
-                       vector<string> const & bibfiles =
+                       vector<FileName> const & bibfiles =
                                        inset.getBibfilesCache(*this);
                        bibfilesCache_.insert(bibfilesCache_.end(),
                                bibfiles.begin(),
@@ -1292,7 +1292,7 @@ void Buffer::updateBibfilesCache()
 }
 
 
-vector<string> const & Buffer::getBibfilesCache() const
+vector<FileName> const & Buffer::getBibfilesCache() const
 {
        // if this is a child document and the parent is already loaded
        // use the parent's cache instead
index c7e34a530e242b7703019a612f92eb4c3301b9d0..6b6addc10bed9281e3efedd1d28810b1226eb46b 100644 (file)
@@ -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<std::string> const & getBibfilesCache() const;
+       std::vector<support::FileName> const & getBibfilesCache() const;
        ///
        void getLabelList(std::vector<docstring> &) 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<std::string> bibfilesCache_;
+       std::vector<support::FileName> bibfilesCache_;
 
        /// Container for all sort of Buffer dependant errors.
        std::map<std::string, ErrorList> errorLists_;
index a8e6905f3b2e006d710c60db2ee47ed49a404dad..09ba80701a377147ee54dc8e4e6c19ff1294067d 100644 (file)
@@ -305,18 +305,18 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
 }
 
 
-vector<string> const InsetBibtex::getFiles(Buffer const & buffer) const
+vector<FileName> const InsetBibtex::getFiles(Buffer const & buffer) const
 {
        Path p(buffer.filePath());
 
-       vector<string> vec;
+       vector<FileName> 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<string> const InsetBibtex::getFiles(Buffer const & buffer) const
 void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
                                  std::vector<std::pair<string, string> > & keys) const
 {
-       vector<string> const files = getFiles(buffer);
-       for (vector<string>::const_iterator it = files.begin();
+       vector<FileName> const files = getFiles(buffer);
+       for (vector<FileName>::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);
index c6ef73bb045057f7695789b2f960aa849638e282..78f9e62dd4742337801fbf311778348622c9204a 100644 (file)
@@ -16,6 +16,8 @@
 #include <vector>
 #include "insetcommand.h"
 
+#include "support/filename.h"
+
 
 namespace lyx {
 
@@ -39,7 +41,7 @@ public:
        void fillWithBibKeys(Buffer const & buffer,
                std::vector<std::pair<std::string,std::string> > & keys) const;
        ///
-       std::vector<std::string> const getFiles(Buffer const &) const;
+       std::vector<support::FileName> const getFiles(Buffer const &) const;
        ///
        bool addDatabase(std::string const &);
        ///
index 5d66cef4366bd5b32696800d00542bdea3eb76ed..fcdbd0be88aed6fdadb49fbb60bdfc41cc4cc9b5 100644 (file)
@@ -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<string, time_t> bibfileStatus;
+       static std::map<FileName, time_t> bibfileStatus;
 
        biblio::InfoMap infomap;
 
-       vector<string> const & bibfilesCache = buffer.getBibfilesCache();
+       vector<FileName> const & bibfilesCache = buffer.getBibfilesCache();
        // compare the cached timestamps with the actual ones.
        bool changed = false;
-       for (vector<string>::const_iterator it = bibfilesCache.begin();
+       for (vector<FileName>::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;
index f374afcba3df206dcef881b31c225e6b6d21ed7a..2a55bf02c74a725f9464fefd017ab21da239d1ea 100644 (file)
@@ -633,17 +633,17 @@ void InsetInclude::updateBibfilesCache(Buffer const & buffer)
 }
 
 
-std::vector<string> const &
+std::vector<FileName> const &
 InsetInclude::getBibfilesCache(Buffer const & buffer) const
 {
        Buffer * const tmp = getChildBuffer(buffer, params_);
        if (tmp) {
                tmp->setParentName("");
-               std::vector<string> const & cache = tmp->getBibfilesCache();
+               std::vector<FileName> const & cache = tmp->getBibfilesCache();
                tmp->setParentName(parentFilename(buffer));
                return cache;
        }
-       static std::vector<string> const empty;
+       static std::vector<FileName> const empty;
        return empty;
 }
 
index 4610e0ea108a08e2781bbd2593a0502e509d4c89..0b2cf430461f3ac1d28b2a5020cc3cc77a5ef227 100644 (file)
@@ -17,6 +17,8 @@
 #include "render_button.h"
 #include "mailinset.h"
 
+#include "support/filename.h"
+
 #include <boost/scoped_ptr.hpp>
 
 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<std::string> const &
+       std::vector<support::FileName> const &
        getBibfilesCache(Buffer const & buffer) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
index b0401e71dd19d5f4ce67dded3e4e134ab6f1725b..825c508a364f871b801d956ece6dde1ac7a968c4 100644 (file)
@@ -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();
 }
 
 
index 3d2eb15bfea11642258a42265966f0065cb72beb..d6bf08897c95b5149c2332fba26efdca855c7894 100644 (file)
@@ -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