diff options
Diffstat (limited to 'mixlib')
| -rw-r--r-- | mixlib/mix_file.c | 10 | ||||
| -rw-r--r-- | mixlib/xmix_io.c | 2 | 
2 files changed, 10 insertions, 2 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; diff --git a/mixlib/xmix_io.c b/mixlib/xmix_io.c index 075b185..b9881c0 100644 --- a/mixlib/xmix_io.c +++ b/mixlib/xmix_io.c @@ -25,7 +25,7 @@  #include <fcntl.h>  #include "xmix_io.h" -const char *io_OPENTYPE_[5] = { "r", "w", "r+", "a", "a+" }; +const char *io_OPENTYPE_[5] = { "r", "w", "w+", "a", "a+" };  /* initialise a mix_iochannel from a file descriptor */ | 
