From 0f9640a5f33d4d0c76df75cb7a6cb07baac049f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 2 May 2021 11:56:25 +0200 Subject: core: split WeeChat home in 4 directories, use XDG directories by default (issue #1285) The 4 directories (which can be the same): - config: configuration files, certificates - data: log/upgrade files, local plugins, scripts, xfer files - cache: script repository, scripts downloaded (temporary location) - runtime: FIFO pipe, relay UNIX sockets --- src/plugins/script/script-repo.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/plugins/script/script-repo.c') diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c index 3627ad2b9..0d4bdd1c0 100644 --- a/src/plugins/script/script-repo.c +++ b/src/plugins/script/script-repo.c @@ -165,28 +165,28 @@ script_repo_search_by_name_ext (const char *name_with_extension) char * script_repo_get_filename_loaded (struct t_script_repo *script) { - char *weechat_home, *filename, resolved_path[PATH_MAX]; + char *weechat_data_dir, *filename, resolved_path[PATH_MAX]; int length; struct stat st; - weechat_home = weechat_info_get ("weechat_dir", NULL); - length = strlen (weechat_home) + strlen (script->name_with_extension) + 64; + weechat_data_dir = weechat_info_get ("weechat_data_dir", NULL); + length = strlen (weechat_data_dir) + strlen (script->name_with_extension) + 64; filename = malloc (length); if (!filename) { - if (weechat_home) - free (weechat_home); + if (weechat_data_dir) + free (weechat_data_dir); return NULL; } snprintf (filename, length, "%s/%s/autoload/%s", - weechat_home, + weechat_data_dir, script_language[script->language], script->name_with_extension); if (stat (filename, &st) != 0) { snprintf (filename, length, "%s/%s/%s", - weechat_home, + weechat_data_dir, script_language[script->language], script->name_with_extension); if (stat (filename, &st) != 0) @@ -195,8 +195,8 @@ script_repo_get_filename_loaded (struct t_script_repo *script) } } - if (weechat_home) - free (weechat_home); + if (weechat_data_dir) + free (weechat_data_dir); if (!filename[0]) { @@ -798,7 +798,7 @@ void script_repo_update_status (struct t_script_repo *script) { const char *version; - char *weechat_home, *filename, *sha512sum; + char *weechat_data_dir, *filename, *sha512sum; struct stat st; int length; struct t_script_repo *ptr_script; @@ -807,13 +807,13 @@ script_repo_update_status (struct t_script_repo *script) sha512sum = NULL; /* check if script is installed (file found on disk) */ - weechat_home = weechat_info_get ("weechat_dir", NULL); - length = strlen (weechat_home) + strlen (script->name_with_extension) + 64; + weechat_data_dir = weechat_info_get ("weechat_data_dir", NULL); + length = strlen (weechat_data_dir) + strlen (script->name_with_extension) + 64; filename = malloc (length); if (filename) { snprintf (filename, length, "%s/%s/autoload/%s", - weechat_home, + weechat_data_dir, script_language[script->language], script->name_with_extension); if (stat (filename, &st) == 0) @@ -825,7 +825,7 @@ script_repo_update_status (struct t_script_repo *script) else { snprintf (filename, length, "%s/%s/%s", - weechat_home, + weechat_data_dir, script_language[script->language], script->name_with_extension); if (stat (filename, &st) == 0) @@ -837,8 +837,8 @@ script_repo_update_status (struct t_script_repo *script) free (filename); } - if (weechat_home) - free (weechat_home); + if (weechat_data_dir) + free (weechat_data_dir); /* check if script is held */ if (script_repo_script_is_held (script)) -- cgit v1.2.3