summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <none@none>2012-07-21 12:10:19 +0200
committerportix <none@none>2012-07-21 12:10:19 +0200
commit0983e0ae429cdef8f2e756df9211dcd0f1c0d0c7 (patch)
treee50ba2db4f1326958e3c780c148551905530cf29 /src/util.c
parentca168a3f42945d8350645f7af7949b8ae5d52c19 (diff)
downloaddwb-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.c8
1 files changed, 4 insertions, 4 deletions
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);