summaryrefslogtreecommitdiff
path: root/src/pwl.c
diff options
context:
space:
mode:
authorDom Lachowicz <domlachowicz@gmail.com>2009-05-22 20:51:41 +0000
committerDom Lachowicz <domlachowicz@gmail.com>2009-05-22 20:51:41 +0000
commit37279c6e3821c5499287a62fe3ea7b11eb6bc853 (patch)
tree282006bc1c1027094eb279a719e85699f5ee2475 /src/pwl.c
parentd4f0ba7cf332d9e42548ecd869a000b91d5d0e5e (diff)
downloadenchant-37279c6e3821c5499287a62fe3ea7b11eb6bc853.tar.gz
Duplicate the code from Glib's g_fopen function, so that Enchant and Glib
don't necessarily have to be built against the same C runtime. git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@26478 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
Diffstat (limited to 'src/pwl.c')
-rw-r--r--src/pwl.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pwl.c b/src/pwl.c
index 0f8cfed..5828c90 100644
--- a/src/pwl.c
+++ b/src/pwl.c
@@ -67,6 +67,7 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include "enchant-provider.h"
#include "pwl.h"
@@ -258,17 +259,17 @@ EnchantPWL* enchant_pwl_init(void)
*/
EnchantPWL* enchant_pwl_init_with_file(const char * file)
{
- int fd;
+ FILE* fd;
EnchantPWL *pwl;
g_return_val_if_fail (file != NULL, NULL);
- fd = g_open(file, O_CREAT | O_RDONLY, S_IREAD | S_IWRITE);
- if(fd == -1)
+ fd = enchant_fopen(file, "wb");
+ if(fd == NULL)
{
return NULL;
}
- close(fd);
+ fclose(fd);
pwl = enchant_pwl_init();
pwl->filename = g_strdup(file);
pwl->file_changed = 0;
@@ -299,7 +300,7 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl)
g_hash_table_destroy (pwl->words_in_trie);
pwl->words_in_trie = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- f = g_fopen(pwl->filename, "r");
+ f = enchant_fopen(pwl->filename, "r");
if (!f)
return;
@@ -393,7 +394,7 @@ void enchant_pwl_add(EnchantPWL *pwl,
{
FILE *f;
- f = g_fopen(pwl->filename, "a");
+ f = enchant_fopen(pwl->filename, "a");
if (f)
{
struct stat stats;
@@ -433,7 +434,7 @@ void enchant_pwl_remove(EnchantPWL *pwl,
if(!g_file_get_contents(pwl->filename, &contents, &length, NULL))
return;
- f = g_fopen(pwl->filename, "wb"); /*binary because g_file_get_contents reads binary*/
+ f = enchant_fopen(pwl->filename, "wb"); /*binary because g_file_get_contents reads binary*/
if (f)
{
const gunichar BOM = 0xfeff;