mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Refine tex2lyx -copyfiles logic.
Now all files are copied if the resulting path is valid. Before the regressions tests would fail depending on the build directory location.
This commit is contained in:
parent
2801f40ad2
commit
e119ba6094
@ -77,7 +77,7 @@ named \fIfoo.lyx.lyx\fR, and the re-exported file will be named
|
||||
\fIfoo.lyx.tex\fR.
|
||||
.TP
|
||||
.BI \-copyfiles
|
||||
Copy all included files below the input directory and that \fBtex2lyx\fR is
|
||||
Copy all included files \fBtex2lyx\fR is
|
||||
aware of to the output directory if the output file is located in a different
|
||||
directory than the input file. This is useful if you want to ensure that no
|
||||
included file is overwritten (either in roundtrip mode or by a later export
|
||||
|
@ -1836,28 +1836,31 @@ void fix_child_filename(string & name)
|
||||
if (!isabs)
|
||||
name = makeAbsPath(name, absMasterTeX).absFileName();
|
||||
bool copyfile = copyFiles();
|
||||
// convert from absolute original path to "relative to master file"
|
||||
string const rel = to_utf8(makeRelPath(from_utf8(name),
|
||||
from_utf8(absMasterTeX)));
|
||||
// Do not copy if the file is not in or below the directory of the
|
||||
// master, since in this case the new path might be impossible to
|
||||
// create. Example:
|
||||
// absMasterTeX = "/foo/bar/"
|
||||
// absMasterLyX = "/bar/"
|
||||
// name = "/baz.eps" => new absolute name would be "/../baz.eps"
|
||||
if (copyfile && rel.substr(0, 3) == "../")
|
||||
copyfile = false;
|
||||
string const absParentLyX = getParentFilePath(false);
|
||||
string abs = name;
|
||||
if (copyfile) {
|
||||
// convert from absolute original path to "relative to master file"
|
||||
string const rel = to_utf8(makeRelPath(from_utf8(name),
|
||||
from_utf8(absMasterTeX)));
|
||||
// re-interpret "relative to .tex file" as "relative to .lyx file"
|
||||
// (is different if the master .lyx file resides in a
|
||||
// different path than the master .tex file)
|
||||
string const absMasterLyX = getMasterFilePath(false);
|
||||
name = makeAbsPath(rel, absMasterLyX).absFileName();
|
||||
if (!isabs) {
|
||||
abs = makeAbsPath(rel, absMasterLyX).absFileName();
|
||||
// Do not copy if the new path is impossible to create. Example:
|
||||
// absMasterTeX = "/foo/bar/"
|
||||
// absMasterLyX = "/bar/"
|
||||
// name = "/baz.eps" => new absolute name would be "/../baz.eps"
|
||||
if (contains(name, "/../"))
|
||||
copyfile = false;
|
||||
}
|
||||
if (copyfile) {
|
||||
if (isabs)
|
||||
name = abs;
|
||||
else {
|
||||
// convert from absolute original path to
|
||||
// "relative to .lyx file"
|
||||
name = to_utf8(makeRelPath(from_utf8(name),
|
||||
name = to_utf8(makeRelPath(from_utf8(abs),
|
||||
from_utf8(absParentLyX)));
|
||||
}
|
||||
}
|
||||
@ -1880,12 +1883,6 @@ void copy_file(FileName const & src, string dstname)
|
||||
else
|
||||
dst = makeAbsPath(dstname, absParent);
|
||||
string const absMaster = getMasterFilePath(false);
|
||||
string const rel = to_utf8(makeRelPath(from_utf8(dst.absFileName()),
|
||||
from_utf8(absMaster)));
|
||||
// Do not copy if the file is not in or below the directory of the
|
||||
// master (see above)
|
||||
if (rel.substr(0, 3) == "../")
|
||||
return;
|
||||
FileName const srcpath = src.onlyPath();
|
||||
FileName const dstpath = dst.onlyPath();
|
||||
if (equivalent(srcpath, dstpath))
|
||||
|
Loading…
Reference in New Issue
Block a user