aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-04-30 20:07:26 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-04-30 20:07:26 +0000
commit6ed457e0621cf05bb6150ba27de0438f34194061 (patch)
tree0409c984fc3ff7ed0197a79909070fceed989d38
parent332485a61701a72ba8c8aa25eef602c4f1ef92a6 (diff)
use canvas_open() and use filenames for sf_open()HEADsvn2git-headexternals/iem/iemmatrix
rather than passing around the fd returned by canvas_open, as this is insecure/incompatible on W32 svn path=/trunk/externals/iem/iemmatrix/; revision=17459
-rw-r--r--src/mtx_sndfileread.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mtx_sndfileread.c b/src/mtx_sndfileread.c
index 3a8f252..9e88e2c 100644
--- a/src/mtx_sndfileread.c
+++ b/src/mtx_sndfileread.c
@@ -141,19 +141,21 @@ static void mtx_sndfileread_open (t_mtx_sndfileread *x, t_symbol *s, t_symbol*ty
{
#ifdef HAVE_SNDFILE_H
char filenamebuf[MAXPDSTRING], *filenamebufptr;
- char*dirname=canvas_getdir(x->x_canvas)->s_name;
int fd;
mtx_sndfileread_close(x);
/* directory, filename, extension, dirresult, nameresult, unsigned int size, int bin */
- if ((fd=open_via_path(dirname,
- s->s_name,"", filenamebuf, &filenamebufptr, MAXPDSTRING,0)) < 0 ) {
- pd_error(x, "%s: failed to open %s", s->s_name, filenamebuf);
+ fd=canvas_open(x->x_canvas, s->s_name, "", filenamebuf, &filenamebufptr, MAXPDSTRING, 1);
+ if(fd<0){
+ pd_error(x, "failed to open %s : %s", s->s_name, filenamebuf);
return;
}
- if (!(x->x_sndfileread = sf_open_fd (fd, SFM_READ, &x->x_sfinfo, 1))) {
- pd_error(x, "%s: failed to sfopen %s", s->s_name, filenamebuf);
+ iemmatrix_fdclose(fd);
+ if(!filenamebufptr[-1])
+ filenamebufptr[-1]='/';
+ if (!(x->x_sndfileread = sf_open (filenamebuf, SFM_READ, &x->x_sfinfo))) {
+ pd_error(x, "failed to sfopen %s : %s", s->s_name, filenamebuf);
mtx_sndfileread_close(x);
return;
}