- Added support for different text files. Now the files are in Media Tree Folder

This commit is contained in:
Santi Noreña 2013-03-01 16:15:11 +01:00
parent 8822bd1927
commit 84c85d5b36
7 changed files with 254 additions and 308 deletions

View file

@ -132,7 +132,7 @@ static void fileselector_output(t_fileselector* x)
{
strncat(path,"/fonts/*",8);
}
if(x->x_type > 255) // Make the path sound
if(x->x_type == 256) // Make the path sound
{
strncat(path,"/sound/*",8);
switch(glob(path, GLOB_TILDE, NULL, &glob_buffer))
@ -150,43 +150,47 @@ static void fileselector_output(t_fileselector* x)
pd_error(x,"[fileselector] nothing found for %s ",path);
break;
# endif
}
i = x->x_folder;
if (i < glob_buffer.gl_pathc)
{
strncpy(path, glob_buffer.gl_pathv[i],strnlen(glob_buffer.gl_pathv[i],FILENAME_MAX));
strncat(path, "/*", 2);
}
else
{
}
i = x->x_folder;
if (i < glob_buffer.gl_pathc)
{
strncpy(path, glob_buffer.gl_pathv[i],strnlen(glob_buffer.gl_pathv[i],FILENAME_MAX));
strncat(path, "/*", 2);
}
else
{
post("fileselector: folder is greater than the number of folders");
globfree(&glob_buffer);
return;
}
}
// Look for the file
switch(glob(path, GLOB_TILDE, NULL,&glob_buffer))
{
case GLOB_NOSPACE:
pd_error(x,"[fileselector] out of memory for \"%s\"",path);
break;
# ifdef GLOB_ABORTED
case GLOB_ABORTED:
}
}
if(x->x_type == 257) // Make the path to texts files
{
strncat(path,"/texts/*",8);
}
// Look for the file
switch(glob(path, GLOB_TILDE, NULL,&glob_buffer))
{
case GLOB_NOSPACE:
pd_error(x,"[fileselector] out of memory for \"%s\"",path);
break;
# ifdef GLOB_ABORTED
case GLOB_ABORTED:
pd_error(x,"[fileselector] aborted \"%s\"",path);
break;
# endif
# ifdef GLOB_NOMATCH
case GLOB_NOMATCH:
pd_error(x,"[fileselector] nothing found for \"%s\"",path);
break;
# endif
}
i = x->x_file;
if (i < glob_buffer.gl_pathc)
{
outlet_symbol(x->x_out, gensym(glob_buffer.gl_pathv[i]));
}
}
break;
# endif
# ifdef GLOB_NOMATCH
case GLOB_NOMATCH:
pd_error(x,"[fileselector] nothing found for \"%s\"",path);
break;
# endif
}
i = x->x_file;
if (i < glob_buffer.gl_pathc)
{
outlet_symbol(x->x_out, gensym(glob_buffer.gl_pathv[i]));
}
}
globfree( &(glob_buffer) );
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.5.0, 2013-02-28T22:02:41. -->
<!-- Written by Qt Creator 2.5.0, 2013-03-01T16:14:51. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>