From 0983e0ae429cdef8f2e756df9211dcd0f1c0d0c7 Mon Sep 17 00:00:00 2001 From: portix Date: Sat, 21 Jul 2012 12:10:19 +0200 Subject: Additional length parameter in util_get_file_content; remove trailing newline in dwb_editor_watch, closing #130 --- src/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index c355c00d..25b153bf 100644 --- a/src/util.c +++ b/src/util.c @@ -302,10 +302,10 @@ util_rmdir(const char *path, gboolean only_content, gboolean recursive) { } /* util_get_file_content(const char *filename) return: char * (alloc) {{{*/ char * -util_get_file_content(const char *filename) { +util_get_file_content(const char *filename, gsize *length) { GError *error = NULL; char *content = NULL; - if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR) && g_file_get_contents(filename, &content, NULL, &error))) { + if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR) && g_file_get_contents(filename, &content, length, &error))) { fprintf(stderr, "Cannot open %s: %s\n", filename, error ? error->message : "file not found"); g_clear_error(&error); } @@ -314,7 +314,7 @@ util_get_file_content(const char *filename) { char ** util_get_lines(const char *filename) { char **ret = NULL; - char *content = util_get_file_content(filename); + char *content = util_get_file_content(filename, NULL); if (content) { ret = g_strsplit(content, "\n", -1); g_free(content); @@ -476,7 +476,7 @@ clean: int util_file_remove_line(const char *filename, const char *line) { int ret = 1; - char *content = util_get_file_content(filename); + char *content = util_get_file_content(filename, NULL); char **lines = g_strsplit(content, "\n", -1); const char *tmp; GString *buffer = g_string_new(NULL); -- cgit v1.2.3