aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2013-02-20 20:58:04 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2013-02-20 20:58:04 +0000
commit4627cd6684d6a7d3b818406091d79b3933fcc55e (patch)
tree73519e5de072541dc9592a06a519f020aedbe98a
parent25401a89dfc004b2587ce3f993748718510ee83f (diff)
fopen and fclose -> sys_fopen and sys_fclose for recent pd
svn path=/trunk/externals/mrpeach/; revision=17044
-rw-r--r--midifile/midifile.c15
1 files 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 <stdio.h>
#include <string.h>
+/* 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;