Re: directory listing
- From: "Sreenidhi.B.G" <nidhi ncoretech com>
- To: Joergen Scheibengruber <Joergen Scheibengruber informatik uni-ulm de>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: directory listing
- Date: Fri, 21 Dec 2001 09:37:49 +0530
thanks a lot,
-sreenidhi,
Joergen Scheibengruber wrote:
Am Don, 2001-12-20 um 14.57 schrieb Sreenidhi.B.G:
Hi all,
is there a way to scan the current directory and get the filenames ,
runtime. I cannot afford to create and display widget, get the selection
and then use "gtk_get_selection_file_name", I'm looking for some way
(API) to get me the filenames in the current directory,
thanks
-sreenidhi
Hi! here is something i did once in a app, i think you can use it:
#include <dirent.h>
#include <sys/types.h>
/* you need to include this */
DIR *dir;
gchar *directory, *tmp;
GList *list;
/* variables */
if ((dir = opendir(directory)) == NULL)
return NULL;
list = NULL;
while (( dir_info = readdir(dir)) != NULL)
{
tmp = g_strjoin("/", directory, dir_info->d_name, NULL);
list = g_list_append(list, (gpointer)tmp);
}
closedir(dir);
list = g_list_sort(list, (GCompareFunc)g_strcasecmp);
/* Thats it all files (with full path) from directory in a sorted GList
:-) */
Maybe there is a function in gnome-vfs that does something similiar, so
you should look there, too...
Greetings,
Jörgen
--
There are two major products that come from Berkeley : LSD and UNIX. We
don't believe this to be a coincidence.
Jeremy S. Anderson
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]