diff options
| author | 2008-08-10 22:44:24 +0200 | |
|---|---|---|
| committer | 2008-08-11 09:33:59 -0700 | |
| commit | 3c052f02933ce1299f136b2d5fb2e6946bf9f1c5 (patch) | |
| tree | 69b529f9309e13c5038a42f43be8ce675e298a4f | |
| parent | 2f2b8d7ea552cbdb5a2cf17ceba364681350f3bb (diff) | |
| download | libimobiledevice-3c052f02933ce1299f136b2d5fb2e6946bf9f1c5.tar.gz libimobiledevice-3c052f02933ce1299f136b2d5fb2e6946bf9f1c5.tar.bz2 | |
Use g_file_get_contents
Signed-off-by: Matt Colyer <matt@colyer.name>
| -rw-r--r-- | src/userpref.c | 29 |
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) | |||
| 162 | return 0; | 162 | return 0; |
| 163 | 163 | ||
| 164 | gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL); | 164 | gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL); |
| 165 | if (g_file_test(filepath, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) { | 165 | gboolean success; |
| 166 | 166 | gsize size; | |
| 167 | FILE * pFile; | 167 | char *content; |
| 168 | 168 | success = g_file_get_contents (filepath, &content, &size, NULL); | |
| 169 | pFile = fopen ( filepath , "rb" ); | 169 | g_free (filepath); |
| 170 | if (pFile==NULL) | 170 | data->data = content; |
| 171 | return 0; | 171 | data->size = size; |
| 172 | 172 | return success; | |
| 173 | fseek (pFile , 0 , SEEK_END); | ||
| 174 | data->size = ftell (pFile); | ||
| 175 | rewind (pFile); | ||
| 176 | |||
| 177 | data->data = (char*)gnutls_malloc(data->size); | ||
| 178 | if (data->data == NULL) | ||
| 179 | return 0; | ||
| 180 | |||
| 181 | // copy the file into the buffer: | ||
| 182 | fread (data->data,1,data->size,pFile); | ||
| 183 | fclose (pFile); | ||
| 184 | } | ||
| 185 | return 1; | ||
| 186 | } | 173 | } |
| 187 | 174 | ||
| 188 | int get_root_private_key(gnutls_datum_t* root_privkey) | 175 | int get_root_private_key(gnutls_datum_t* root_privkey) |
