From 4627cd6684d6a7d3b818406091d79b3933fcc55e Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Wed, 20 Feb 2013 20:58:04 +0000 Subject: fopen and fclose -> sys_fopen and sys_fclose for recent pd svn path=/trunk/externals/mrpeach/; revision=17044 --- midifile/midifile.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/midifile/midifile.c b/midifile/midifile.c index de87d1a..bd28d22 100644 --- a/midifile/midifile.c +++ b/midifile/midifile.c @@ -24,6 +24,13 @@ #include #include +/* support older Pd versions without sys_open(), sys_fopen(), sys_fclose() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_open open +#define sys_fopen fopen +#define sys_fclose fclose +#endif + #define NO_MORE_ELEMENTS 0xFFFFFFFF static t_class *midifile_class; @@ -185,12 +192,12 @@ static void midifile_close(t_midifile *x) { if (x->fP != NULL) { - fclose (x->fP); + sys_fclose (x->fP); x->fP = NULL; } if (x->tmpFP != NULL) { - fclose(x->tmpFP); + sys_fclose(x->tmpFP); x->tmpFP = NULL; } x->fPath[0] = '\0'; @@ -238,7 +245,7 @@ static int midifile_open_path(t_midifile *x, char *path, char *mode) /* ...if it doesn't work we won't mess up x->fPath */ tryPath[PATH_BUF_SIZE-1] = '\0'; /* just make sure there is a null termination */ if (x->verbosity > 1)post("midifile_open_path (absolute): %s\n", tryPath); - fP = fopen(tryPath, mode); + fP = sys_fopen(tryPath, mode); } if (fP == NULL) { @@ -249,7 +256,7 @@ static int midifile_open_path(t_midifile *x, char *path, char *mode) /* ...if it doesn't work we won't mess up x->fPath */ tryPath[PATH_BUF_SIZE-1] = '\0'; /* just make sure there is a null termination */ if (x->verbosity > 1)post("midifile_open_path (relative): %s\n", tryPath); - fP = fopen(tryPath, mode); + fP = sys_fopen(tryPath, mode); } if (fP == NULL) return 0; x->fP = fP; -- cgit v1.2.1