Fix hardcoded uses of "/tmp"

Closes #1032
This commit is contained in:
Maxime Coste 2016-12-20 04:04:47 +00:00
parent 5e2c47a7fd
commit 4b696836d1

View File

@ -746,8 +746,10 @@ Server::Server(String session_name)
bool Server::rename_session(StringView name) bool Server::rename_session(StringView name)
{ {
String old_socket_file = format("/tmp/kakoune/{}/{}", getpwuid(geteuid())->pw_name, m_session); String old_socket_file = format("{}/kakoune/{}/{}", tmpdir(),
String new_socket_file = format("/tmp/kakoune/{}/{}", getpwuid(geteuid())->pw_name, name); getpwuid(geteuid())->pw_name, m_session);
String new_socket_file = format("{}/kakoune/{}/{}", tmpdir(),
getpwuid(geteuid())->pw_name, name);
if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0) if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0)
return false; return false;
@ -760,7 +762,8 @@ void Server::close_session(bool do_unlink)
{ {
if (do_unlink) if (do_unlink)
{ {
String socket_file = format("/tmp/kakoune/{}/{}", getpwuid(geteuid())->pw_name, m_session); String socket_file = format("{}/kakoune/{}/{}", tmpdir(),
getpwuid(geteuid())->pw_name, m_session);
unlink(socket_file.c_str()); unlink(socket_file.c_str());
} }
m_listener->close_fd(); m_listener->close_fd();