From c811c3a2adfa1832310aa66a7200232e8839b36f Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 29 Mar 2008 15:37:22 +0000 Subject: [PATCH] Add calcInzipName. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24040 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/EmbeddedFiles.cpp | 14 +++++++++++--- src/EmbeddedFiles.h | 9 ++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/EmbeddedFiles.cpp b/src/EmbeddedFiles.cpp index a6450073cf..63b46ceb3f 100644 --- a/src/EmbeddedFiles.cpp +++ b/src/EmbeddedFiles.cpp @@ -368,11 +368,13 @@ 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) +// static +std::string EmbeddedFile::calcInzipName( + std::string const & file, std::string const & buffer_path) { - string inzipName = to_utf8(makeRelPath(from_utf8(absFilename()), + string inzipName = to_utf8(makeRelPath(from_utf8(file), from_utf8(buffer_path))); - + if (FileName(inzipName).isAbsolute()) inzipName = absDirName + '/' + inzipName; @@ -390,6 +392,12 @@ std::string EmbeddedFile::calcInzipName(std::string const & buffer_path) } +std::string EmbeddedFile::calcInzipName(std::string const & buffer_path) +{ + return calcInzipName(absFilename(), buffer_path); +} + + void EmbeddedFile::syncInzipFile(std::string const & buffer_path) { BOOST_ASSERT(enabled()); diff --git a/src/EmbeddedFiles.h b/src/EmbeddedFiles.h index cca8e5e8e8..a263bb39df 100644 --- a/src/EmbeddedFiles.h +++ b/src/EmbeddedFiles.h @@ -171,10 +171,13 @@ public: /// Calculate checksum of availableFile unsigned long checksum() const; - // calculate inzip_name_ from filename + /// calculate inzip_name_ from filename + static std::string + calcInzipName(std::string const & file, std::string const & path); + /// calculate inzip_name_ from filename std::string calcInzipName(std::string const & buffer_path); - // move an embedded disk file with an existing inzip_name_ to - // a calculated inzip_name_, if they differ. + /// move an embedded disk file with an existing inzip_name_ to + /// a calculated inzip_name_, if they differ. void syncInzipFile(std::string const & buffer_path); private: