+$temp/$embDirName/$absDirName/a/absolute/path for /a/absolute/path
+
+*/
+const std::string embDirName = "LyX.Embedded.Files";
+const std::string upDirName = "LyX.Embed.Dir.Up";
+const std::string absDirName = "LyX.Embed.Dir.Abs";
+const std::string driveName = "LyX.Embed.Drive";
+const std::string spaceName = "LyX.Embed.Space";
+
+std::string EmbeddedFile::calcInzipName(std::string const & buffer_path)
+{
+ string inzipName = to_utf8(makeRelPath(from_utf8(absFilename()),
+ from_utf8(buffer_path)));
+
+ if (FileName(inzipName).isAbsolute())
+ inzipName = absDirName + '/' + inzipName;
+
+ // replace .. by upDirName
+ if (prefixIs(inzipName, "."))
+ inzipName = subst(inzipName, "..", upDirName);
+ // replace special characters by their value
+ inzipName = subst(inzipName, ":", driveName);
+ inzipName = subst(inzipName, " ", spaceName);
+
+ // to avoid name conflict between $docu_path/file and $temp_path/file
+ // embedded files are in a subdirectory of $temp_path.
+ inzipName = embDirName + '/' + inzipName;
+ return inzipName;