mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-08 12:24:55 +00:00
client: move log file to spicec appdata dir
This commit is contained in:
parent
15fff174eb
commit
db5375a5f8
@ -55,6 +55,8 @@
|
||||
mutex_t cairo_surface_user_data_mutex;
|
||||
#endif
|
||||
|
||||
static const char* app_name = "spicec";
|
||||
|
||||
void ConnectedEvent::response(AbstractProcessLoop& events_loop)
|
||||
{
|
||||
static_cast<Application*>(events_loop.get_owner())->on_connected();
|
||||
@ -1600,8 +1602,8 @@ bool Application::process_cmd_line(int argc, char** argv)
|
||||
|
||||
_host_auth_opt.type_flags = RedPeer::HostAuthOptions::HOST_AUTH_OP_NAME;
|
||||
|
||||
Platform::get_spice_config_dir(_host_auth_opt.CA_file);
|
||||
_host_auth_opt.CA_file += CA_FILE_NAME;
|
||||
Platform::get_app_data_dir(_host_auth_opt.CA_file, app_name);
|
||||
Platform::path_append(_host_auth_opt.CA_file, CA_FILE_NAME);
|
||||
|
||||
parser.begin(argc, argv);
|
||||
|
||||
@ -1754,15 +1756,17 @@ bool Application::process_cmd_line(int argc, char** argv)
|
||||
|
||||
void Application::init_logger()
|
||||
{
|
||||
std::string temp_dir_name;
|
||||
Platform::get_temp_dir(temp_dir_name);
|
||||
std::string log_file_name = temp_dir_name + "spicec.log";
|
||||
std::string log_file_name;
|
||||
Platform::get_app_data_dir(log_file_name, app_name);
|
||||
Platform::path_append(log_file_name, "spicec.log");
|
||||
|
||||
int fd = ::open(log_file_name.c_str(), O_CREAT | O_APPEND | O_WRONLY, 0644);
|
||||
|
||||
if (fd == -1) {
|
||||
log4cpp::BasicConfigurator::configure();
|
||||
return;
|
||||
}
|
||||
|
||||
log4cpp::Category& root = log4cpp::Category::getRoot();
|
||||
#ifdef RED_DEBUG
|
||||
root.setPriority(log4cpp::Priority::DEBUG);
|
||||
|
||||
@ -38,6 +38,8 @@ public:
|
||||
static void yield();
|
||||
static uint64_t get_monolithic_time();
|
||||
static void get_temp_dir(std::string& path);
|
||||
static void get_app_data_dir(std::string& path, const std::string& app_name);
|
||||
static void path_append(std::string& path, const std::string& partial_path);
|
||||
static uint64_t get_process_id();
|
||||
static uint64_t get_thread_id();
|
||||
|
||||
@ -47,8 +49,6 @@ public:
|
||||
|
||||
static void send_quit_request();
|
||||
|
||||
static void get_spice_config_dir(std::string& path);
|
||||
|
||||
enum ThreadPriority {
|
||||
PRIORITY_INVALID,
|
||||
PRIORITY_TIME_CRITICAL,
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
#include "cursor.h"
|
||||
#include "named_pipe.h"
|
||||
|
||||
#define SPICE_CONFIG_DIR "spicec\\"
|
||||
|
||||
int gdi_handlers = 0;
|
||||
extern HINSTANCE instance;
|
||||
|
||||
@ -432,6 +430,7 @@ bool Platform::is_monitors_pos_valid()
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void Platform::get_spice_config_dir(std::string& path)
|
||||
{
|
||||
char app_data_path[MAX_PATH];
|
||||
@ -446,6 +445,29 @@ void Platform::get_spice_config_dir(std::string& path)
|
||||
}
|
||||
path += SPICE_CONFIG_DIR;
|
||||
}
|
||||
*/
|
||||
|
||||
static void Platform::get_app_data_dir(std::string& path, const std::string& app_name);
|
||||
{
|
||||
char app_data_path[MAX_PATH];
|
||||
HRESULT res = SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, app_data_path);
|
||||
if (res != S_OK) {
|
||||
throw Exception("get user app data dir failed");
|
||||
}
|
||||
|
||||
path = app_data_path;
|
||||
path_append(path, app_name);
|
||||
|
||||
if (!CreateDirectory(path.c_str()) && GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
throw Exception("create user app data dir failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void Platform::path_append(std::string& path, const std::string& partial_path)
|
||||
{
|
||||
path += "\\";
|
||||
path += partial_path;
|
||||
}
|
||||
|
||||
void Platform::init()
|
||||
{
|
||||
|
||||
@ -64,8 +64,6 @@
|
||||
#define USE_XRANDR_1_2
|
||||
#endif
|
||||
|
||||
#define SPICE_CONFIG_DIR ".spicec/"
|
||||
|
||||
static Display* x_display = NULL;
|
||||
static bool x_shm_avail = false;
|
||||
static XVisualInfo **vinfo = NULL;
|
||||
@ -1897,16 +1895,27 @@ bool Platform::is_monitors_pos_valid()
|
||||
return (ScreenCount(x_display) == 1);
|
||||
}
|
||||
|
||||
void Platform::get_spice_config_dir(std::string& path)
|
||||
void Platform::get_app_data_dir(std::string& path, const std::string& app_name)
|
||||
{
|
||||
char* home_dir = getenv("HOME");
|
||||
const char* home_dir = getenv("HOME");
|
||||
|
||||
if (!home_dir) {
|
||||
throw Exception("get home dir failed");
|
||||
}
|
||||
|
||||
path = home_dir;
|
||||
path += "/.";
|
||||
path += app_name;
|
||||
|
||||
if (mkdir(path.c_str(), 0700) == -1 && errno != EEXIST) {
|
||||
throw Exception("create appdata dir failed");
|
||||
}
|
||||
}
|
||||
|
||||
void Platform::path_append(std::string& path, const std::string& partial_path)
|
||||
{
|
||||
path += "/";
|
||||
path += SPICE_CONFIG_DIR;
|
||||
path += partial_path;
|
||||
}
|
||||
|
||||
static void root_win_proc(XEvent& event)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user