diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/freadln.c | 2 | ||||
-rw-r--r-- | src/msgfile.c | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/freadln.c b/src/freadln.c index c78a0bd..e8e09bb 100644 --- a/src/freadln.c +++ b/src/freadln.c @@ -106,7 +106,7 @@ static void freadln_open (t_freadln *x, t_symbol *s, t_symbol*type) pd_error(x, "%s: failed to open %s", s->s_name, filenamebuf); return; } - close(fd); + z_close(fd); len=strlen(filenamebuf); if (!(x->x_filename=(char*)getbytes(sizeof(char)*(len+strlen(s->s_name)+2)))) { pd_error(x, "out of memory"); diff --git a/src/msgfile.c b/src/msgfile.c index 208c476..ac004c4 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -38,6 +38,7 @@ + /* ****************************************************************************** */ /* msgfile : save and load messages... */ @@ -647,17 +648,21 @@ static void msgfile_read2(t_msgfile *x, t_symbol *filename, t_symbol *format) rmode |= O_BINARY; #endif - if ((fd = open_via_path(dirname, - filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0) { - - if((fd=open(filename->s_name, rmode)) < 0) { + fd = open_via_path(dirname, + filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0); + + if (fd < 0) { + /* open via path failed, fall back */ + fd=open(filename->s_name, rmode); + if(fd < 0) { pd_error(x, "can't open in %s/%s", dirname, filename->s_name); return; } else { + close(fd); sprintf(filnam, "%s", filename->s_name); } } else { - close(fd); + z_close(fd); sprintf(filnam, "%s/%s", buf, bufptr); } @@ -673,7 +678,6 @@ static void msgfile_read2(t_msgfile *x, t_symbol *filename, t_symbol *format) if (!(readbuf = t_getbytes(length))) { pd_error(x, "msgfile_read: could not reserve %ld bytes to read into", length); fclose(fil); - close(fd); return; } |