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);
}
}
}
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());
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(),
}
-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
#include "dociterator.h"
#include "ParagraphList_fwd.h"
+#include "support/filename.h"
#include "support/limited_stack.h"
#include "support/types.h"
#include "support/docstring.h"
namespace lyx {
-namespace support { class FileName; }
-
class BufferParams;
class ErrorItem;
class FuncRequest;
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;
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_;
}
-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
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);
#include <vector>
#include "insetcommand.h"
+#include "support/filename.h"
+
namespace lyx {
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 &);
///
using support::ascii_lowercase;
using support::contains;
+using support::FileName;
using support::getStringFromVector;
using support::getVectorFromString;
using support::ltrim;
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;
}
-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;
}
#include "render_button.h"
#include "mailinset.h"
+#include "support/filename.h"
+
#include <boost/scoped_ptr.hpp>
namespace lyx {
* 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; }
}
-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
// 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
<< "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();
}
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