summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/en/weechat_plugin_api.en.txt7
-rw-r--r--src/core/wee-upgrade.c1
-rw-r--r--src/core/wee-util.c15
-rw-r--r--src/core/wee-util.h3
-rw-r--r--src/plugins/plugin.c3
-rw-r--r--src/plugins/scripts/script.c2
-rw-r--r--src/plugins/weechat-plugin.h10
8 files changed, 28 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 61d9aff13..4c521ae3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
FlashCode <flashcode@flashtux.org>
-v0.3.0-dev, 2009-06-13
+v0.3.0-dev, 2009-06-14
Version 0.3.0 (under dev!)
@@ -38,6 +38,7 @@ Version 0.3.0 (under dev!)
protocol), go.py (quick jump to buffers), buffers.pl (sidebar with list of
buffers), iset.pl (set options interactively), weetris.pl (tetris-like game),
mastermind.pl, ...
+* scripts: do not auto-load hidden files (bug #21390)
* api: add hooks: command, timer, file descriptor, process, connection, print,
signal, config, completion, modifier, info, infolist
* api: new plugin API with many new functions: hooks, buffer management and
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 0a85a58ff..5d7c02c92 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -1549,7 +1549,9 @@ Prototype:
[source,C]
----------------------------------------
-void weechat_exec_on_files (const char *directory, void *data,
+void weechat_exec_on_files (const char *directory,
+ int hidden_files,
+ void *data,
int (*callback)(void *data,
const char *filename));
----------------------------------------
@@ -1557,6 +1559,7 @@ void weechat_exec_on_files (const char *directory, void *data,
Arguments:
* 'directory': directory for searching files
+* 'hidden_files': include hidden files
* 'data': pointer given to callback when it is called by WeeChat
* 'callback': function called for each file found, arguments:
** 'void *data': pointer
@@ -1572,7 +1575,7 @@ int callback (void *data, const char *filename)
return 1;
}
...
-weechat_exec_on_files (plugin, "/tmp", &callback);
+weechat_exec_on_files ("/tmp", 0, NULL, &callback);
----------------------------------------
[[util]]
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index c7fa6f425..b42f5d506 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -615,6 +615,7 @@ void
upgrade_weechat_remove_files ()
{
util_exec_on_files (weechat_home,
+ 0,
NULL,
&upgrade_weechat_remove_file_cb);
}
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 1aef2ac6f..bfdc38be5 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -255,7 +255,7 @@ util_mkdir_parents (const char *directory, int mode)
*/
void
-util_exec_on_files (const char *directory, void *data,
+util_exec_on_files (const char *directory, int hidden_files, void *data,
void (*callback)(void *data, const char *filename))
{
char complete_filename[1024];
@@ -271,12 +271,15 @@ util_exec_on_files (const char *directory, void *data,
{
while ((entry = readdir (dir)))
{
- snprintf (complete_filename, sizeof (complete_filename) - 1,
- "%s/%s", directory, entry->d_name);
- lstat (complete_filename, &statbuf);
- if (!S_ISDIR(statbuf.st_mode))
+ if (hidden_files || (entry->d_name[0] != '.'))
{
- (*callback) (data, complete_filename);
+ snprintf (complete_filename, sizeof (complete_filename) - 1,
+ "%s/%s", directory, entry->d_name);
+ lstat (complete_filename, &statbuf);
+ if (!S_ISDIR(statbuf.st_mode))
+ {
+ (*callback) (data, complete_filename);
+ }
}
}
closedir (dir);
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 5b9d8230a..03932a5b4 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -28,7 +28,8 @@ extern void util_catch_signal (int signum, void (*handler)(int));
extern int util_mkdir_home (const char *directory, int mode);
extern int util_mkdir (const char *directory, int mode);
extern int util_mkdir_parents (const char *directory, int mode);
-extern void util_exec_on_files (const char *directory, void *data,
+extern void util_exec_on_files (const char *directory, int hidden_files,
+ void *data,
void (*callback)(void *data,
const char *filename));
extern char *util_search_full_lib_name (const char *filename,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 037bb4f1a..1299e77c9 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -697,6 +697,7 @@ plugin_auto_load ()
util_exec_on_files ((plugin_path2) ?
plugin_path2 : ((plugin_path) ?
plugin_path : CONFIG_STRING(config_plugin_path)),
+ 0,
NULL,
&plugin_auto_load_file);
if (plugin_path)
@@ -711,7 +712,7 @@ plugin_auto_load ()
{
snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16,
"%s/plugins", WEECHAT_LIBDIR);
- util_exec_on_files (dir_name, NULL, &plugin_auto_load_file);
+ util_exec_on_files (dir_name, 0, NULL, &plugin_auto_load_file);
free (dir_name);
}
}
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index 24f23c3d3..6837b888a 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -404,7 +404,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
snprintf (dir_name, dir_length,
"%s/%s/autoload", dir_home, weechat_plugin->name);
- weechat_exec_on_files (dir_name, NULL, callback);
+ weechat_exec_on_files (dir_name, 0, NULL, callback);
free (dir_name);
}
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index d921c7371..ea84b1176 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -33,7 +33,7 @@ struct t_infolist;
struct t_weelist;
/* API version (used to check that plugin has same API and can be loaded) */
-#define WEECHAT_PLUGIN_API_VERSION "20090614-01"
+#define WEECHAT_PLUGIN_API_VERSION "20090614-02"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -193,7 +193,7 @@ struct t_weechat_plugin
int (*mkdir_home) (const char *directory, int mode);
int (*mkdir) (const char *directory, int mode);
int (*mkdir_parents) (const char *directory, int mode);
- void (*exec_on_files) (const char *directory, void *data,
+ void (*exec_on_files) (const char *directory, int hidden_files, void *data,
void (*callback)(void *data, const char *filename));
/* util */
@@ -751,8 +751,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->mkdir(__directory, __mode)
#define weechat_mkdir_parents(__directory, __mode) \
weechat_plugin->mkdir_parents(__directory, __mode)
-#define weechat_exec_on_files(__directory, __data, __callback) \
- weechat_plugin->exec_on_files(__directory, __data, __callback)
+#define weechat_exec_on_files(__directory, __hidden_files, __data, \
+ __callback) \
+ weechat_plugin->exec_on_files(__directory, __hidden_files, __data, \
+ __callback)
/* util */
#define weechat_timeval_cmp(__time1, __time2) \