1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 20:06:38 +02:00

scripts: create directories (language and language/autoload) on each action (install/remove/autoload), just in case they have been removed (bug #38473)

This commit is contained in:
Sebastien Helleu
2013-03-17 18:45:55 +01:00
parent cf2ad51f62
commit a290589f7c
2 changed files with 37 additions and 11 deletions
+33 -9
View File
@@ -78,6 +78,29 @@ plugin_script_config_cb (void *data, const char *option, const char *value)
return WEECHAT_RC_OK;
}
/*
* Creates directories for plugin in WeeChat home:
* - ~/.weechat/XXX/
* - ~/.weechat/XXX/autoload/
*/
void
plugin_script_create_dirs (struct t_weechat_plugin *weechat_plugin)
{
char *string;
int length;
weechat_mkdir_home (weechat_plugin->name, 0755);
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
string = malloc (length);
if (string)
{
snprintf (string, length, "%s/autoload", weechat_plugin->name);
weechat_mkdir_home (string, 0755);
free (string);
}
}
/*
* Initializes script plugin:
* - reads configuration
@@ -112,15 +135,7 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
}
/* create directories in WeeChat home */
weechat_mkdir_home (weechat_plugin->name, 0755);
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
string = malloc (length);
if (string)
{
snprintf (string, length, "%s/autoload", weechat_plugin->name);
weechat_mkdir_home (string, 0755);
free (string);
}
plugin_script_create_dirs (weechat_plugin);
/* add command */
completion = NULL;
@@ -952,6 +967,9 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
if (!*list)
return;
/* create again directories, just in case they have been removed */
plugin_script_create_dirs (weechat_plugin);
ptr_list = *list;
autoload = 0;
*quiet = 0;
@@ -1094,6 +1112,9 @@ plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
if (!*list)
return;
/* create again directories, just in case they have been removed */
plugin_script_create_dirs (weechat_plugin);
ptr_list = *list;
*quiet = 0;
if (strncmp (ptr_list, "-q ", 3) == 0)
@@ -1146,6 +1167,9 @@ plugin_script_action_autoload (struct t_weechat_plugin *weechat_plugin,
if (!*list)
return;
/* create again directories, just in case they have been removed */
plugin_script_create_dirs (weechat_plugin);
ptr_list = *list;
autoload = 0;
*quiet = 0;