summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-11-29 23:54:35 +0100
committerportix <portix@gmx.net>2011-11-29 23:54:35 +0100
commit135b9897126049e6c9fca754516e2f075e68d935 (patch)
tree09683573277b9c619fd31fad5e8ab152c674caf0 /src/util.c
parent32bd841a45c3ebe540d158a58ba5910316c4c87e (diff)
downloaddwb-135b9897126049e6c9fca754516e2f075e68d935.zip
Introducing scripts with suffix .all.js, these sripts are applied to all frames
--HG-- rename : scripts/autoscroll.js => scripts/autoscroll.all.js
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/util.c b/src/util.c
index 76968b18..43d564c3 100644
--- a/src/util.c
+++ b/src/util.c
@@ -260,26 +260,34 @@ util_get_directory_entries(const char *path, const char *text) {
}/*}}}*/
/*util_get_directory_content(GString **, const char *filename) {{{*/
void
-util_get_directory_content(GString **buffer, const char *dirname) {
+util_get_directory_content(GString **buffer, const char *dirname, const char *extension) {
GDir *dir;
char *content;
GError *error = NULL;
char *filename, *filepath;
+ char *firstdot;
if ( (dir = g_dir_open(dirname, 0, NULL)) ) {
while ( (filename = (char*)g_dir_read_name(dir)) ) {
- if (filename[0] != '.') {
- filepath = g_build_filename(dirname, filename, NULL);
- if (g_file_get_contents(filepath, &content, NULL, &error)) {
- g_string_append((*buffer), content);
- }
- else {
- fprintf(stderr, "Cannot read %s: %s\n", filename, error->message);
- g_clear_error(&error);
- }
- FREE(filepath);
- FREE(content);
+ if (*filename == '.')
+ continue;
+ if (extension) {
+ firstdot = strchr(filename, '.');
+ if (!firstdot)
+ continue;
+ if (strcmp(firstdot+1, extension))
+ continue;
+ }
+ filepath = g_build_filename(dirname, filename, NULL);
+ if (g_file_get_contents(filepath, &content, NULL, &error)) {
+ g_string_append((*buffer), content);
+ }
+ else {
+ fprintf(stderr, "Cannot read %s: %s\n", filename, error->message);
+ g_clear_error(&error);
}
+ FREE(filepath);
+ FREE(content);
}
g_dir_close (dir);
}