mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Don't update paths of non-existing files
This commit is contained in:
parent
68ee68103a
commit
d0146c8e82
@ -5023,17 +5023,21 @@ void Buffer::checkMasterBuffer()
|
||||
}
|
||||
|
||||
|
||||
string Buffer::includedFilePath(string const & name) const
|
||||
string Buffer::includedFilePath(string const & name, string const & ext) const
|
||||
{
|
||||
if (d->old_position.empty() || d->old_position == filePath())
|
||||
bool isabsolute = FileName::isAbsolute(name);
|
||||
// old_position already contains a trailing path separator
|
||||
string const absname = isabsolute ? name : d->old_position + name;
|
||||
|
||||
if (d->old_position.empty() || d->old_position == filePath()
|
||||
|| !FileName(addExtension(absname, ext)).exists())
|
||||
return name;
|
||||
|
||||
if (FileName::isAbsolute(name))
|
||||
if (isabsolute)
|
||||
return to_utf8(makeRelPath(from_utf8(name), from_utf8(filePath())));
|
||||
|
||||
// old_position already contains a trailing path separator
|
||||
string const cleanpath = FileName(d->old_position + name).realPath();
|
||||
return to_utf8(makeRelPath(from_utf8(cleanpath), from_utf8(filePath())));
|
||||
return to_utf8(makeRelPath(from_utf8(FileName(absname).realPath()),
|
||||
from_utf8(filePath())));
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
11
src/Buffer.h
11
src/Buffer.h
@ -713,11 +713,14 @@ public:
|
||||
///
|
||||
void checkMasterBuffer();
|
||||
|
||||
/// If the document is being saved to a new location, return the
|
||||
/// updated path of an included file relative to the new buffer path
|
||||
/// if possible, otherwise return its absolute path.
|
||||
/// If the document is being saved to a new location and the named file
|
||||
/// exists at the old location, return its updated path relative to the
|
||||
/// new buffer path if possible, otherwise return its absolute path.
|
||||
/// In all other cases, this is a no-op and name is returned unchanged.
|
||||
std::string includedFilePath(std::string const & name) const;
|
||||
/// If a non-empty ext is given, the existence of name.ext is checked
|
||||
/// but the returned path will not contain this extension.
|
||||
std::string includedFilePath(std::string const & name,
|
||||
std::string const & ext = empty_string()) const;
|
||||
|
||||
/// compute statistics between \p from and \p to
|
||||
/// \p from initial position
|
||||
|
@ -346,7 +346,7 @@ void InsetCommandParams::Write(ostream & os, Buffer const * buffer) const
|
||||
string newdata;
|
||||
string bib = token(data, ',', i);
|
||||
while (!bib.empty()) {
|
||||
bib = buffer->includedFilePath(bib);
|
||||
bib = buffer->includedFilePath(bib, "bib");
|
||||
if (!newdata.empty())
|
||||
newdata.append(1, ',');
|
||||
newdata.append(bib);
|
||||
|
Loading…
Reference in New Issue
Block a user