Change-Id: Ibf121f7f1af21d3a6328dfa8d3d6bd7c63808ffc
#include "common/dbus_client.h"
#include "common/logger.h"
+#include "common/file_utils.h"
namespace wrt {
bool DBusClient::ConnectByName(const std::string& name) {
std::string address("unix:path=");
- address.append(g_get_user_runtime_dir());
+ address.append(utils::GetUserRuntimeDir());
address.append("/.");
address.append(name);
return Connect(address);
#include "common/dbus_server.h"
#include "common/logger.h"
+#include "common/file_utils.h"
namespace wrt {
GError* err = NULL;
address_path_.clear();
- address_path_.append(g_get_user_runtime_dir());
+ address_path_.append(utils::GetUserRuntimeDir());
address_path_.append("/.");
address_path_.append(name);
// unlink existing bus address
#include <unistd.h>
#include <libgen.h>
+#include <sys/types.h>
+
#include <string>
+#include <sstream>
#include <algorithm>
namespace wrt {
}
}
+std::string GetUserRuntimeDir() {
+ uid_t uid = getuid();
+ std::stringstream ss;
+ ss << "/run/user/" << uid;
+ std::string path = ss.str();
+ if (!Exists(path)) {
+ path = "/tmp";
+ }
+ return path;
+}
+
} // namespace utils
} // namespace wrt
std::string ExtName(const std::string& path);
+std::string GetUserRuntimeDir();
} // namespace utils
} // namespace wrt