コード例 #1
0
void CheckDir( GtkWidget * list,char * directory )
{
 struct stat     fs;
 int             i;
 glob_t          gg;

 if ( !fsFilter[0] ) return;

 gtk_widget_hide( list );
 gtk_clist_clear( GTK_CLIST( list ) );

 clist_append_fname(list, ".",  dpixmap, dmask);
 clist_append_fname(list, "..", dpixmap, dmask);

 glob( "*",0,NULL,&gg );
 for(  i=0;(unsigned)i<gg.gl_pathc;i++ )
  {
   stat( gg.gl_pathv[i],&fs );
   if( !S_ISDIR( fs.st_mode ) ) continue;
   clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask);
  }
 globfree( &gg );

 if ( strchr( fsFilter,',' ) )
  {
   char tmp[8];
   int  i,c,glob_param = 0;
   for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ )
    {
     tmp[c]=fsFilter[i];
     if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) )
      {
       tmp[c]=0; c=-1;
       glob( Filter( tmp ),glob_param,NULL,&gg );
       glob_param=GLOB_APPEND;
      }
    }
  } else glob( Filter( fsFilter ),0,NULL,&gg );

 for(  i=0;(unsigned)i<gg.gl_pathc;i++ )
  {
   stat( gg.gl_pathv[i],&fs );
   if(  S_ISDIR( fs.st_mode ) ) continue;
   clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask);
  }
 globfree( &gg );

 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 );
 gtk_clist_select_row( GTK_CLIST( list ),0,1 );
 gtk_widget_show( list );
}
コード例 #2
0
ファイル: fileselect.c プロジェクト: jlelli/mplayer-dl
static void CheckDir( GtkWidget * list )
{
 struct stat     fs;
 unsigned int    i, j, fn;
 glob_t          gg;
 gchar          *filter, **fext;

 if ( !fsFilter[0] ) return;

 gtk_widget_hide( list );
 gtk_clist_clear( GTK_CLIST( list ) );

 clist_append_fname(list, ".",  dpixmap, dmask);
 clist_append_fname(list, "..", dpixmap, dmask);

 glob( "*",0,NULL,&gg );
 for(  i=0;i<gg.gl_pathc;i++ )
  {
   if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || !S_ISDIR( fs.st_mode ) ) continue;
   clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask);
  }

 for (fn = 1, i = 0; fsFilter[i]; i++)
   if (fsFilter[i] == ',') fn++;

 filter = g_strdup(fsFilter);
 fext = calloc(fn, sizeof(gchar *));

 if (filter && fext)
 {
   for (j = 0, i = 0; filter[i]; i++)
   {
     if (filter[i] == '.') fext[j] = filter + i;

     if (filter[i] == ',')
     {
       filter[i] = 0;
       j++;
     }
   }

   for(  i=0;i<gg.gl_pathc;i++ )
   {
     char *ext;

     if( ( stat( gg.gl_pathv[i],&fs ) != 0 ) || S_ISDIR( fs.st_mode ) ) continue;

     ext = strrchr(gg.gl_pathv[i], '.');

     if (ext || !fext[0])
     {
       for (j = 0; j < fn; j++)
       {
         if (fext[j] == NULL || strcasecmp(fext[j], ext) == 0)
         {
           clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask);
           break;
         }
       }
     }
   }
 }

 free(fext);
 g_free(filter);
 globfree( &gg );

 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 );
 gtk_widget_show( list );
}