Re: [gtk-list] Re: file selection dialog



On Thu, 15 Oct 1998, Brandon Long wrote:

> On 10/16/98 Scott Stone uttered the following other thing:
> > On Thu, 15 Oct 1998 padraig@turing.idc.ul.ie wrote:
> > 
> > > 
> > > hi,
> > > 
> > > when you collect the filename from the file selection dialog using
> > > 
> > > filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION(fs) );
> > > 
> > > it returns the full path of the filename. my question is: is there any
> > > quick way to get just the filename (i.e. without the path) or do you
> > > have to extract it (from the longer string) yourself?
> > 
> > It's easy, just:
> > 
> > char *s1=rindex(filename,'/');
> > s1++;
> > 
> > now, s1 is your base filename, without the path.
> 
> is rindex deprecated?  If so, strrchr would be a better bet:

strrchr is standard C anyway, and that's always a better choice.

> 
> char *s1 = strrchr (filename, '/');
> if (s1)
> {
>   filename = s1 + 1;
> }
> 
> Brandon
> -- 
>  Brandon Long             "... a boy who gets a 'C-minus' in
>  MD6 Crash Test Dummy     Appreciation of Televison can't be all bad."
>  Intel Corporation            -- Robert Heinlein,  _Starship Troopers_ 
>           I'm too low on the totem pole to speak for Intel.
> 		  http://www.fiction.net/blong/
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 

-------------------------------------------------------------------------------
Jason A. Pfeil, Computer Science Graduate Student      101 Carothers Hall
http://www.cs.fsu.edu/~pfeil			       C3527 University Center
pfeil@cs.fsu.edu				       (850)644-8014



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