1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +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
+4 -2
View File
@@ -71,11 +71,13 @@ Version 0.4.1 (under dev!)
* rmodifier: rename default rmodifier "nickserv" to "command_auth" (with new
modifier "irc_command_auth"), add default rmodifier "message_auth" (modifier
"irc_message_auth")
* script: create "script" directory on each action (just in case it has been
removed) (bug #38472)
* script: create "script" directory on each action, just in case it has been
removed (bug #38472)
* script: add option script.scripts.autoload, add options "autoload",
"noautoload" and "toggleautoload" for command /script, add action "A" (meta-A)
on script buffer (toggle autoload) (task #12393)
* scripts: create directories (language and language/autoload) on each action
(install/remove/autoload), just in case they have been removed (bug #38473)
* scripts: do not allow empty script name in function "register"
* xfer: fix freeze of DCC file received: use non-blocking socket after
connection to sender and ensure the ACK is properly sent (bug #38340)
+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;