diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-03-17 18:45:55 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-03-17 18:45:55 +0100 |
commit | a290589f7cb3c4d59afa1a3a9a67f0b7eda4720a (patch) | |
tree | 894cbe4db8e662fc08c599378247c439ac294aca /src/plugins | |
parent | cf2ad51f627a2db65959c6bf75f06a18d0c2d1f3 (diff) | |
download | weechat-a290589f7cb3c4d59afa1a3a9a67f0b7eda4720a.zip |
scripts: create directories (language and language/autoload) on each action (install/remove/autoload), just in case they have been removed (bug #38473)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin-script.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index 3f311cccc..8acfe54cf 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -79,6 +79,29 @@ plugin_script_config_cb (void *data, const char *option, const char *value) } /* + * 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 * - hooks config @@ -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; |