diff options
author | portix <none@none> | 2012-07-21 12:10:19 +0200 |
---|---|---|
committer | portix <none@none> | 2012-07-21 12:10:19 +0200 |
commit | 0983e0ae429cdef8f2e756df9211dcd0f1c0d0c7 (patch) | |
tree | e50ba2db4f1326958e3c780c148551905530cf29 /src/util.c | |
parent | ca168a3f42945d8350645f7af7949b8ae5d52c19 (diff) | |
download | dwb-0983e0ae429cdef8f2e756df9211dcd0f1c0d0c7.zip |
Additional length parameter in util_get_file_content; remove trailing newline in dwb_editor_watch, closing #130
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); |