Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13824
Modified Files: Tag: desiredata desire.c m_pd.h Log Message: added canvas_open2, which allocate its own dirresult
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.4.4.11.2.33.2.54 retrieving revision 1.4.4.11.2.33.2.55 diff -C2 -d -r1.4.4.11.2.33.2.54 -r1.4.4.11.2.33.2.55 *** m_pd.h 18 Jul 2007 18:36:52 -0000 1.4.4.11.2.33.2.54 --- m_pd.h 19 Jul 2007 01:13:14 -0000 1.4.4.11.2.33.2.55 *************** *** 456,460 ****
EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir); ! EXTERN void canvas_setargs(int argc, t_atom *argv); EXTERN void canvas_getargs(int *argcp, t_atom **argvp); EXTERN t_symbol *canvas_getcurrentdir(void); --- 456,460 ----
EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir); ! EXTERN void canvas_setargs(int argc, t_atom * argv ); EXTERN void canvas_getargs(int *argcp, t_atom **argvp); EXTERN t_symbol *canvas_getcurrentdir(void); *************** *** 464,469 **** EXTERN t_symbol *canvas_getdir(t_glist *x); EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b); ! EXTERN int canvas_open(t_canvas *x, const char *name, const char *ext, ! char *dirresult, char **nameresult, unsigned int size, int bin);
/* -------------------- classes -------------- */ --- 464,469 ---- EXTERN t_symbol *canvas_getdir(t_glist *x); EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b); ! EXTERN int canvas_open( t_canvas *x, const char *name, const char *ext, char * dirresult, char **nameresult, unsigned int size, int bin); ! EXTERN int canvas_open2(t_canvas *x, const char *name, const char *ext, char **dirresult, char **nameresult, int bin);
/* -------------------- classes -------------- */
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.166 retrieving revision 1.1.2.217.2.167 diff -C2 -d -r1.1.2.217.2.166 -r1.1.2.217.2.167 *** desire.c 18 Jul 2007 23:55:24 -0000 1.1.2.217.2.166 --- desire.c 19 Jul 2007 01:13:12 -0000 1.1.2.217.2.167 *************** *** 1981,1994 **** static void garray_read(t_garray *x, t_symbol *filename) { FILE *fd; ! char buf[MAXPDSTRING], *bufptr; int yonset, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) int nelem = array->n; ! int filedesc = canvas_open(canvas_getcanvas(x->canvas), filename->name, "", buf, &bufptr, MAXPDSTRING, 0); ! if (filedesc<0 || !(fd = fdopen(filedesc, "r"))) { ! pd_error(x,"%s: can't open", filename->name); ! return; ! } int i; for (i=0; i < nelem; i++) { --- 1981,1992 ---- static void garray_read(t_garray *x, t_symbol *filename) { FILE *fd; ! char *buf, *bufptr; int yonset, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) int nelem = array->n; ! int filedesc = canvas_open2(canvas_getcanvas(x->canvas), filename->name, "", &buf, &bufptr, 0); ! if (filedesc<0) {pd_error(x,"%s: can't open", filename->name); free(buf); return;} ! if (!(fd = fdopen(filedesc, "r"))) {pd_error(x,"%s: can't open", filename->name); free(buf); return;} int i; for (i=0; i < nelem; i++) { *************** *** 2001,2004 **** --- 1999,2003 ---- fclose(fd); garray_redraw(x); + free(buf); }
*************** *** 6922,6926 **** open is attempted, otherwise ASCII (this only matters on Microsoft.) If "x" is zero, the file is sought in the directory "." or in the global path.*/ ! static int canvas_open_2(t_canvas *x, const char *name, const char *ext, char **dirresult, char **nameresult, int bin) { int fd = -1; /* first check if "name" is absolute (and if so, try to open) */ --- 6921,6925 ---- open is attempted, otherwise ASCII (this only matters on Microsoft.) If "x" is zero, the file is sought in the directory "." or in the global path.*/ ! int canvas_open2(t_canvas *x, const char *name, const char *ext, char **dirresult, char **nameresult, int bin) { int fd = -1; /* first check if "name" is absolute (and if so, try to open) */ *************** *** 6946,6950 **** int canvas_open(t_canvas *x, const char *name, const char *ext, char *dirresult, char **nameresult, unsigned int size, int bin) { char *dirr; ! int r = canvas_open_2(x,name,ext,&dirr,nameresult,bin); if (dirr) {strncpy(dirresult,dirr,size); dirresult[size-1]=0; free(dirr);} return r; --- 6945,6949 ---- int canvas_open(t_canvas *x, const char *name, const char *ext, char *dirresult, char **nameresult, unsigned int size, int bin) { char *dirr; ! int r = canvas_open2(x,name,ext,&dirr,nameresult,bin); if (dirr) {strncpy(dirresult,dirr,size); dirresult[size-1]=0; free(dirr);} return r;