diff options
Diffstat (limited to 'mixlib/mix_file.c')
-rw-r--r-- | mixlib/mix_file.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mixlib/mix_file.c b/mixlib/mix_file.c index 6ee88ec..ac623f6 100644 --- a/mixlib/mix_file.c +++ b/mixlib/mix_file.c @@ -48,9 +48,17 @@ open_file_(const gchar *name, mix_fmode_t mode) { mix_file_t *result; FILE *file; + const gchar *fmode = fmode_to_type_ (mode); + + /* if the read/write file already exists, open in r+ mode */ + if (mode == mix_io_RDWRT && (file = fopen (name, "r"))) + { + fmode = "r+"; + fclose (file); + } result = g_new(mix_file_t, 1); - file = fopen(name, fmode_to_type_(mode)); + file = fopen(name, fmode); if ( file == NULL ) { g_free (result); return NULL; |