- Added folders to images
This commit is contained in:
parent
7be7febfce
commit
8822bd1927
7 changed files with 200 additions and 97 deletions
|
@ -1,10 +1,10 @@
|
|||
/* --------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* object for getting files from a source tree
|
||||
/* object for getting files names in a source tree structure
|
||||
|
||||
Copyright (c) 2013 Santi Noreña <belfegor@gmail.com>
|
||||
|
||||
Based on folderlist by Hans-Christoph Steiner <hans@eds.org> */
|
||||
|
||||
|
||||
/* This program is free software; you can redistribute it and/or */
|
||||
/* modify it under the terms of the GNU General Public License */
|
||||
|
@ -38,7 +38,7 @@ static t_class *fileselector_class;
|
|||
typedef struct _fileselector {
|
||||
t_object x_obj;
|
||||
t_symbol* x_pattern;
|
||||
int x_folder;
|
||||
int x_folder;
|
||||
int x_file;
|
||||
int x_type;
|
||||
t_outlet *x_out;
|
||||
|
@ -50,25 +50,24 @@ typedef struct _fileselector {
|
|||
|
||||
static void fileselector_output(t_fileselector* x)
|
||||
{
|
||||
if (strlen(x->x_pattern->s_name) < 6)
|
||||
{
|
||||
post("fileselector: Set path first");
|
||||
return;
|
||||
}
|
||||
char path[FILENAME_MAX] = "";
|
||||
glob_t glob_buffer;
|
||||
unsigned int i;
|
||||
strncpy(path, x->x_pattern->s_name, FILENAME_MAX);
|
||||
if(sys_isabsolutepath(path)) {
|
||||
if(x->x_type < 25) // Make the path video
|
||||
if (strlen(x->x_pattern->s_name) < 6)
|
||||
{
|
||||
post("fileselector: Set path first");
|
||||
return;
|
||||
}
|
||||
if(x->x_type < 25) // Don't make anything
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
char path[FILENAME_MAX] = "";
|
||||
glob_t glob_buffer;
|
||||
unsigned int i;
|
||||
strncpy(path, x->x_pattern->s_name, FILENAME_MAX);
|
||||
if(sys_isabsolutepath(path)) {
|
||||
if((x->x_type > 24) && (x->x_type<50)) // Make the path video
|
||||
{
|
||||
strncat(path,"/video/*",8);
|
||||
glob_t glob_video;
|
||||
switch(glob(path, GLOB_TILDE, NULL, &glob_video))
|
||||
strncat(path,"/video/*",8);
|
||||
switch(glob(path, GLOB_TILDE, NULL, &glob_buffer))
|
||||
{
|
||||
case GLOB_NOSPACE:
|
||||
pd_error(x,"[fileselector] out of memory for \"%s\"",path);
|
||||
|
@ -85,32 +84,22 @@ static void fileselector_output(t_fileselector* x)
|
|||
# endif
|
||||
}
|
||||
i = x->x_folder;
|
||||
if (i < glob_video.gl_pathc)
|
||||
if (i < glob_buffer.gl_pathc)
|
||||
{
|
||||
strncpy(path, glob_video.gl_pathv[i],strnlen(glob_video.gl_pathv[i],FILENAME_MAX));
|
||||
strncpy(path, glob_buffer.gl_pathv[i],strnlen(glob_buffer.gl_pathv[i],FILENAME_MAX));
|
||||
strncat(path, "/*", 2);
|
||||
globfree(&glob_video);
|
||||
}
|
||||
else
|
||||
{
|
||||
post("fileselector: folder is greater than the number of folders");
|
||||
globfree(&glob_video);
|
||||
globfree(&glob_buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if((x->x_type > 49) && (x->x_type<75)) // Make the path image
|
||||
{
|
||||
strncat(path,"/image/*",8);
|
||||
}
|
||||
if((x->x_type > 74) && (x->x_type<100)) // Make the path image
|
||||
{
|
||||
strncat(path,"/fonts/*",8);
|
||||
}
|
||||
if(x->x_type > 255) // Make the path sound
|
||||
{
|
||||
strncat(path,"/sound/*",8);
|
||||
glob_t glob_audio;
|
||||
switch(glob(path, GLOB_TILDE, NULL, &glob_audio))
|
||||
strncat(path,"/image/*",8);
|
||||
switch(glob(path, GLOB_TILDE, NULL, &glob_buffer))
|
||||
{
|
||||
case GLOB_NOSPACE:
|
||||
pd_error(x,"[fileselector] out of memory for \"%s\"",path);
|
||||
|
@ -127,41 +116,76 @@ static void fileselector_output(t_fileselector* x)
|
|||
# endif
|
||||
}
|
||||
i = x->x_folder;
|
||||
if (i < glob_audio.gl_pathc)
|
||||
if (i < glob_buffer.gl_pathc)
|
||||
{
|
||||
strncpy(path, glob_audio.gl_pathv[i],strnlen(glob_audio.gl_pathv[i],FILENAME_MAX));
|
||||
strncpy(path, glob_buffer.gl_pathv[i],strnlen(glob_buffer.gl_pathv[i],FILENAME_MAX));
|
||||
strncat(path, "/*", 2);
|
||||
globfree(&glob_audio);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
post("fileselector: folder is greater than the number of folders");
|
||||
globfree(&glob_audio);
|
||||
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:
|
||||
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]));
|
||||
}
|
||||
}
|
||||
if((x->x_type > 74) && (x->x_type<100)) // Make the fonts path
|
||||
{
|
||||
strncat(path,"/fonts/*",8);
|
||||
}
|
||||
if(x->x_type > 255) // Make the path sound
|
||||
{
|
||||
strncat(path,"/sound/*",8);
|
||||
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_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:
|
||||
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]));
|
||||
}
|
||||
}
|
||||
globfree( &(glob_buffer) );
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue