]> git.lyx.org Git - features.git/commitdiff
\origin handling. Use realPath() intead of absFileName()
authorKornel Benko <kornel@lyx.org>
Sun, 13 Dec 2015 11:25:32 +0000 (12:25 +0100)
committerKornel Benko <kornel@lyx.org>
Sun, 13 Dec 2015 11:25:32 +0000 (12:25 +0100)
This change avoids misinterpreting paths containing symbolic parts.
Without this, lyx may not find its own sysdir.

src/BufferParams.cpp

index 029e5b524c27cbb1c2c900b99c57f76b5e7f8f64..ee9f535f9978fe7906bf1b3c39240855535601da 100644 (file)
@@ -1016,10 +1016,15 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        // Prints out the buffer info into the .lyx file given by file
 
        // the document directory
-       string filepath = buf->filePath();
-       string const sysdir = package().system_support().absFileName();
-       if (prefixIs(filepath, sysdir))
+       // use realPath() instead of absFileName() for comparing
+       // so we can catch also eventually used symbolic parts of the path.
+       string filepath = buf->fileName().onlyPath().realPath();
+       string const sysdir = package().system_support().realPath();
+       if (prefixIs(filepath, sysdir)) {
                filepath.replace(0, sysdir.length(), "/systemlyxdir/");
+               // Remove eventually added superfluous "/"
+               filepath = subst(filepath, "//", "/");
+       }
        else if (!lyxrc.save_origin)
                filepath = "unavailable";
        os << "\\origin " << quoteIfNeeded(filepath) << '\n';