diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index ba8eff8..6995e24 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -8,6 +8,12 @@ #include "faust_tilde_options.h" #include +#ifdef _WIN32 +#include +#else +#include +#endif + #define MAXFAUSTSTRING 4096 typedef struct _faust_opt_manager @@ -208,22 +214,24 @@ char faust_opt_has_double_precision(t_faust_opt_manager const *x) char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* name) { - if(sys_isabsolutepath(name)) - { - return name; - } - else if(x->f_directory && x->f_directory->s_name && name) + if(x->f_directory && x->f_directory->s_name && name) { - char* file = (char *)getbytes(MAXFAUSTSTRING * sizeof(char)); - if(file) + char patht[MAXFAUSTSTRING], path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *bufptr; + int filedesc = open_via_path(x->f_directory->s_name, name, ".dsp", realdir, &bufptr, MAXPDSTRING, 0); + if(filedesc < 0) + { + pd_error(x->f_owner, "faustgen~: can't find the FAUST DSP file %s.dsp", name); + return NULL; + } + else { - sprintf(file, "%s/%s.dsp", x->f_directory->s_name, name); - x->f_temp_path = gensym(file); - freebytes(file, MAXFAUSTSTRING * sizeof(char)); - return x->f_temp_path->s_name; + close(filedesc); } - pd_error(x->f_owner, "faustgen~: memory allocation failed - path"); - return NULL; + + sprintf(patht, "%s/%s.dsp", realdir, name); + sys_unbashfilename(patht, path); + x->f_temp_path = gensym(path); + return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); return NULL; diff --git a/tests/location.pd b/tests/location.pd new file mode 100644 index 0000000..8e26c6f --- /dev/null +++ b/tests/location.pd @@ -0,0 +1,23 @@ +#N canvas 471 124 627 394 10; +#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 286 135 \; pd dsp \$1; +#X obj 32 308 dac~ 1 2; +#X obj 31 47 osc~ 220; +#X msg 49 71 compile; +#X obj 124 282 print; +#X msg 70 95 compileoptions -single; +#X msg 70 125 compileoptions -double; +#X msg 70 155 compileoptions -single -double; +#X obj 31 241 ../external/faustgen~ location, f 16; +#X text 172 222 location.dsp must be located in the Pd search path +, f 23; +#X connect 0 0 1 0; +#X connect 3 0 9 0; +#X connect 4 0 9 0; +#X connect 6 0 9 0; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 2 0; +#X connect 9 0 2 1; +#X connect 9 1 5 0;