Skip to content

Commit

Permalink
look for the DSP file in all Pd's search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Aug 23, 2018
1 parent 41aaa25 commit 2f99806
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/faust_tilde_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include "faust_tilde_options.h"
#include <string.h>

#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#define MAXFAUSTSTRING 4096

typedef struct _faust_opt_manager
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions tests/location.pd
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 2f99806

Please sign in to comment.