summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2008-08-10 22:44:24 +0200
committerGravatar Matt Colyer2008-08-11 09:33:59 -0700
commit3c052f02933ce1299f136b2d5fb2e6946bf9f1c5 (patch)
tree69b529f9309e13c5038a42f43be8ce675e298a4f
parent2f2b8d7ea552cbdb5a2cf17ceba364681350f3bb (diff)
downloadlibplist-3c052f02933ce1299f136b2d5fb2e6946bf9f1c5.tar.gz
libplist-3c052f02933ce1299f136b2d5fb2e6946bf9f1c5.tar.bz2
Use g_file_get_contents
Signed-off-by: Matt Colyer <matt@colyer.name>
-rw-r--r--src/userpref.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/userpref.c b/src/userpref.c
index 1dfc6ff..c792d1f 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -162,27 +162,14 @@ int read_file_in_confdir(char* file, gnutls_datum_t* data)
return 0;
gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL);
- if (g_file_test(filepath, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
-
- FILE * pFile;
-
- pFile = fopen ( filepath , "rb" );
- if (pFile==NULL)
- return 0;
-
- fseek (pFile , 0 , SEEK_END);
- data->size = ftell (pFile);
- rewind (pFile);
-
- data->data = (char*)gnutls_malloc(data->size);
- if (data->data == NULL)
- return 0;
-
- // copy the file into the buffer:
- fread (data->data,1,data->size,pFile);
- fclose (pFile);
- }
- return 1;
+ gboolean success;
+ gsize size;
+ char *content;
+ success = g_file_get_contents (filepath, &content, &size, NULL);
+ g_free (filepath);
+ data->data = content;
+ data->size = size;
+ return success;
}
int get_root_private_key(gnutls_datum_t* root_privkey)