aboutsummaryrefslogtreecommitdiff
path: root/src/msgfile.c
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-02-18 13:23:10 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-02-18 13:23:10 +0000
commit4d2c9c4794908547f833e99f4704593950ba727b (patch)
tree5be2293ec0cf1177ec68b4dd07a50b456df35fe3 /src/msgfile.c
parent9374577aed19eafbe2406f40a9a1fd3e9360c1c9 (diff)
use z_close() when appropriate
svn path=/trunk/externals/zexy/; revision=17428
Diffstat (limited to 'src/msgfile.c')
-rw-r--r--src/msgfile.c16
1 files changed, 10 insertions, 6 deletions
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;
}