more unicode filenames

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16127 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-12-01 20:09:08 +00:00
parent 5f4e6d9a7c
commit 5afcd541fd
10 changed files with 38 additions and 33 deletions

View 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);
}
}
}

View 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

View 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_;

View 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);

View 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 &);
///

View 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;

View 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;
}

View 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; }

View 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();
}

View 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