Re: [gtk-list] Re: file globbing



I'm afraid I haven't actually used the g_completion functions before, just
the gtk_pattern functions - I think something like this would work for
your example:

GtkPatternSpec spec;
DIR *dp;
struct dirent *de;

gtk_pattern_spec_init (&spec, "*.bar");

dp = opendir ("/foo/bar");
while (de = readdir (dp))
{
	if (gtk_pattern_match_string (&spec, g_basename (de))
		printf ("%s\n", g_basename (de));
}
closedir (dp);


Well, something like that - normally you'd check return values and all,
but I'm lazy - you get the idea :)

--
Evan Lawrence

On Thu, 25 Mar 1999, Daniel J. Kressin wrote:

> On Thu, 25 Mar 1999, Evan Lawrence wrote:
> 
> >The gtk_pattern functions sound like what you're looking for -
> >their function names and source can be found in gtkbindings.[ch], which,
> >of course, is in the gtk+ package. There are also the g_completion
> >functions in glib - function defs are in the glib.h file, and source is in
> >gcompletion.c ... Hope this helps.
> 
> I've gone and looked at those files, but I can't really make heads or
> tails of them.  For example, how am I to interpret the sample
> matches/patterns listed in the GtkMatchType enum?  (The "*A?A*", "*A?AA",
> etc.)
> 
> As much as I'd love to figure this stuff out on my own, I have a deadline
> quickly approaching and need to concentrate my efforts elsewhere.  Can
> someone please give a sample piece of code that simply prints the names of
> the files matching "*.bar" in directory "./foo"?
> 
> Many thanks in advance.
> 
> Dan 
>  ____    Kressin   ____   .-----------------------------------. 
> /___ \____________/ __ \  | dkressin@acm.org                  |
>     \  \    /      /  \ | | Lead Programmer/Analyst           |
>  ___/ __\/\/rench_ \__/ | | University of Wisconsin - Oshkosh |
> \____/            \____/  | www.mio.uwosh.edu/~kressd11/      |
>                           `-----------------------------------'
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]