diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index a78cef1d8..6ff84ae65 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -1783,46 +1783,6 @@ String Utility::ValidateUTF8(const String& input) return String(std::move(output)); } -String Utility::CreateTempFile(const String& path, int mode, std::fstream& fp) -{ - std::vector targetPath(path.Begin(), path.End()); - targetPath.push_back('\0'); - - int fd; -#ifndef _WIN32 - fd = mkstemp(&targetPath[0]); -#else /* _WIN32 */ - fd = MksTemp(&targetPath[0]); -#endif /*_WIN32*/ - - if (fd < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("mkstemp") - << boost::errinfo_errno(errno) - << boost::errinfo_file_name(path)); - } - - try { - fp.open(&targetPath[0], std::ios_base::trunc | std::ios_base::out); - } catch (const std::fstream::failure&) { - close(fd); - throw; - } - - close(fd); - - String resultPath = String(targetPath.begin(), targetPath.end() - 1); - - if (chmod(resultPath.CStr(), mode) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("chmod") - << boost::errinfo_errno(errno) - << boost::errinfo_file_name(resultPath)); - } - - return resultPath; -} - #ifdef _WIN32 /* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright * (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc. diff --git a/lib/base/utility.hpp b/lib/base/utility.hpp index 6f9d03d44..47b68d251 100644 --- a/lib/base/utility.hpp +++ b/lib/base/utility.hpp @@ -132,8 +132,6 @@ public: static String ValidateUTF8(const String& input); - static String CreateTempFile(const String& path, int mode, std::fstream& fp); - #ifdef _WIN32 static int MksTemp(char *tmpl); #endif /* _WIN32 */