loolwsd/Util.cpp | 10 ++++++++++ loolwsd/Util.hpp | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-)
New commits: commit 230b295d9162385cd48e1e9028093a92187cba13 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri May 13 08:44:22 2016 -0400 loolwsd: improve temp file creation and delayed delete Change-Id: I174b87f1aceaacee58121bc60edb420004e69c44 Reviewed-on: https://gerrit.libreoffice.org/24967 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 68b8b2af4f154f99612762c1ff2d7b2197a23162) Reviewed-on: https://gerrit.libreoffice.org/25386 diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 519cb66..a814ae2 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -36,6 +36,7 @@ #include <Poco/Process.h> #include <Poco/Thread.h> #include <Poco/Timestamp.h> +#include <Poco/TemporaryFile.h> #include <Poco/Util/Application.h> #include "Common.hpp" @@ -127,6 +128,15 @@ namespace Util } } + std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename) + { + const std::string srcPath = srcDir + '/' + srcFilename; + const std::string dstPath = Poco::Path::temp() + encodeId(rng::getNext()) + '_' + srcFilename; + Poco::File(srcPath).copyTo(dstPath); + Poco::TemporaryFile::registerForDeletion(dstPath); + return dstPath; + } + bool windowingAvailable() { return std::getenv("DISPLAY") != nullptr; diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 28cdb94..5340899 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -90,17 +90,7 @@ namespace Util /// Primarily used by tests to avoid tainting the originals. /// srcDir shouldn't end with '/' and srcFilename shouldn't contain '/'. /// Returns the created file path. - inline - std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename) - { - const std::string srcPath = srcDir + '/' + srcFilename; - - std::string dstPath = std::tmpnam(nullptr); - dstPath += '_' + srcFilename; - - Poco::File(srcPath).copyTo(dstPath); - return dstPath; - } + std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename); /// Returns the name of the signal. const char *signalName(int signo); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits