- string result;
- string const basename = support::ChangeExtension(
- support::OnlyFilename(filename), string());
- string const absname = support::MakeAbsPath(filename, parentpath);
- string const filepath = support::OnlyPath(filename);
- string const abspath = support::OnlyPath(absname);
- string const masterpath = external_in_tmpdir ?
- m_buffer->temppath() :
- m_buffer->filePath();
- string relToMasterPath = support::OnlyPath(
- support::MakeRelPath(absname, masterpath));
- if (relToMasterPath == "./")
- relToMasterPath.clear();
- string relToParentPath = support::OnlyPath(
- support::MakeRelPath(absname, parentpath));
- if (relToParentPath == "./")
- relToParentPath.clear();
-
- result = support::subst(s, "$$FName", filename);
- result = support::subst(result, "$$Basename", basename);
- result = support::subst(result, "$$Extension",
- '.' + support::GetExtension(filename));
- result = support::subst(result, "$$FPath", filepath);
- result = support::subst(result, "$$AbsPath", abspath);
- result = support::subst(result, "$$RelPathMaster", relToMasterPath);
- result = support::subst(result, "$$RelPathParent", relToParentPath);
- if (support::AbsolutePath(filename)) {
- result = support::subst(result, "$$AbsOrRelPathMaster",
- abspath);
- result = support::subst(result, "$$AbsOrRelPathParent",
- abspath);
- } else {
- result = support::subst(result, "$$AbsOrRelPathMaster",
- relToMasterPath);
- result = support::subst(result, "$$AbsOrRelPathParent",
- relToParentPath);
+ string const basename = support::changeExtension(
+ support::onlyFilename(filename), string());
+ string const absname = support::makeAbsPath(filename, parentpath).absFilename();
+
+ string result = s;
+ if (what != ALL_BUT_PATHS) {
+ string const filepath = support::onlyPath(filename);
+ string const abspath = support::onlyPath(absname);
+ string const masterpath = external_in_tmpdir ?
+ m_buffer->temppath() :
+ m_buffer->filePath();
+ string relToMasterPath = support::onlyPath(
+ support::makeRelPath(absname, masterpath));
+ if (relToMasterPath == "./")
+ relToMasterPath.clear();
+ string relToParentPath = support::onlyPath(
+ support::makeRelPath(absname, parentpath));
+ if (relToParentPath == "./")
+ relToParentPath.clear();
+
+ result = subst_path(result, "$$FPath", filepath,
+ use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ result = subst_path(result, "$$AbsPath", abspath,
+ use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ result = subst_path(result, "$$RelPathMaster",
+ relToMasterPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ result = subst_path(result, "$$RelPathParent",
+ relToParentPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ if (support::absolutePath(filename)) {
+ result = subst_path(result, "$$AbsOrRelPathMaster",
+ abspath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ result = subst_path(result, "$$AbsOrRelPathParent",
+ abspath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ } else {
+ result = subst_path(result, "$$AbsOrRelPathMaster",
+ relToMasterPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ result = subst_path(result, "$$AbsOrRelPathParent",
+ relToParentPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
+ }