first take at filetype functionality
@@ -33,6 +33,7 @@ before used to always bang on callback, now only bangs now due to new x->x_fileb
#define COLLTHREAD 1 //default is threaded
#define COLLEMBED 0 //default for save in patch
#define COLL_ALLBANG 1 //bang all when read instead of specific object
+#define COLL_FILENAME 100 //filename max size
enum { COLL_HEADRESET,
COLL_HEADNEXT, COLL_HEADPREV, /* distinction not used, currently */
@@ -100,6 +101,7 @@ typedef struct _coll
pthread_cond_t unsafe_cond;
t_symbol *x_s;
+ t_symbol *x_fileext;
t_int unsafe;
t_int init; //used to make sure that the secondary thread is ready to go
@@ -1903,7 +1905,14 @@ static void coll_write(t_coll *x, t_symbol *s)
if (!x->unsafe) {
t_collcommon *cc = x->x_common;
if (s && s != &s_) {
- x->x_s = s;
+ char buf[MAXPDSTRING];
+ if(x->x_fileext != &s_)
+ {
+ strncpy(buf, s->s_name, MAXPDSTRING - 5); // period + 3 char ext + null
+ strcat(buf, x->x_fileext->s_name);
+ x->x_s = gensym(buf);
+ }
+ else x->x_s = s;
if (x->x_threaded == 1) {
x->unsafe = 10;
@@ -1973,6 +1982,16 @@ static void coll_writeagain(t_coll *x)
static void coll_filetype(t_coll *x, t_symbol *s)
{
/* dummy */
+ if(s != &s_)
+ {
+ if(strcmp(s -> s_name, "text") == 0) x->x_fileext = gensym(".txt");
+ else if(strcmp(s -> s_name, "csv") == 0) x->x_fileext = gensym(".csv");
+ else x->x_fileext = &s_;
+ }
+ else
+ {
+ x->x_fileext = &s_;
+ };
}
static void coll_dump(t_coll *x)
