From 7312e58d17e331d71d4f47e21bf15499609bace8 Mon Sep 17 00:00:00 2001 From: dieter kovacic Date: Tue, 9 Jul 2002 12:41:56 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r33, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ext13/; revision=34 --- strippath.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 strippath.c (limited to 'strippath.c') diff --git a/strippath.c b/strippath.c new file mode 100644 index 0000000..f24be9e --- /dev/null +++ b/strippath.c @@ -0,0 +1,68 @@ +#include "ext13.h" +#include "m_pd.h" +#include +#include +#include +#include + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* -------------------------- strippath ------------------------------ */ +static t_class *strippath_class; + +typedef struct _strippath +{ + t_object x_obj; + t_symbol *x_s; + t_symbol *x_path; +} t_strippath; + + +static void *strippath_new(t_symbol *s) +{ + t_strippath *x = (t_strippath *)pd_new(strippath_class); + x->x_s = s; + x->x_path=gensym("./"); + symbolinlet_new(&x->x_obj, &x->x_path); + outlet_new(&x->x_obj, &s_symbol); + return (x); +} + + + +static void strippath_symbol(t_strippath *x, t_symbol *s) +{ + char *lastslash; + char path[MAXPDSTRING], filename[MAXPDSTRING]; + x->x_s = s; + lastslash=strrchr (s->s_name,'/'); + if (lastslash){ + strncpy (path,s->s_name,lastslash-s->s_name+1); + path[lastslash-s->s_name]=0; + strcpy (filename,lastslash+1); +// filename[lastslash-s->s_name+1]=0; + } + else { + strcpy (filename,s->s_name); + sprintf (path,x->x_path->s_name); + } + outlet_symbol(x->x_obj.ob_outlet,gensym(filename)); +// post ("path:%s , name:%s",path,filename); +} + + +static void strippath_bang(t_strippath *x) +{ + if (x->x_s){strippath_symbol (x,x->x_s);} +} + +void strippath_setup(void) +{ + strippath_class = class_new(gensym("strippath"), (t_newmethod)strippath_new, 0, + sizeof(t_strippath), 0, A_DEFFLOAT, 0); + class_addbang(strippath_class, strippath_bang); + class_addsymbol(strippath_class, strippath_symbol); +} -- cgit v1.2.1