g_dir_open hangs?!
- From: Andy Jeffries <andy-lists i-a co uk>
- To: gtk-app-devel-list gnome org
- Subject: g_dir_open hangs?!
- Date: 19 Feb 2003 12:53:51 +0000
OK, next GTK+ question that I should really know the answer to ;-)
I have created the code below. It's supposed go through a folder
recursively examining any subfolders and adding files to a GSList using
the classbrowser_filelist_add function.
However, if I run the function twice, once with
"/home/andy/gphpedit/gphpedit-0.0.45", then with
"/home/andy/gphpedit/website" it works fine.
dir_opened for /home/andy/gphpedit/gphpedit-0.0.45
dir_open succeeded for /home/andy/gphpedit/gphpedit-0.0.45
dir_closed for /home/andy/gphpedit/gphpedit-0.0.45
dir_opened for /home/andy/gphpedit/gphpedit-0.0.45
dir_open succeeded for /home/andy/gphpedit/gphpedit-0.0.45
dir_closed for /home/andy/gphpedit/gphpedit-0.0.45
dir_opened for /home/andy/gphpedit/website
dir_open succeeded for /home/andy/gphpedit/website
dir_opened for /home/andy/gphpedit/website/old-v1
dir_open succeeded for /home/andy/gphpedit/website/old-v1
dir_closed for /home/andy/gphpedit/website/old-v1
dir_opened for /home/andy/gphpedit/website/.xvpics
dir_open succeeded for /home/andy/gphpedit/website/.xvpics
dir_closed for /home/andy/gphpedit/website/.xvpics
dir_closed for /home/andy/gphpedit/website
The next time I come to run it (and I've emptied the lists and set them
to be NULL) it hangs after just printing:
dir_opened for /home/andy/gphpedit/gphpedit-0.0.45
This is the only line printed so it's the g_dir_open that's hanging.
Any ideas,
Andy Jeffries
void classbrowser_dirlist_add(gchar *dir)
{
GDir *dir_iter;
GError *error = NULL;
gchar *file;
GString *fullfilename;
g_print("dir_opened for %s\n", dir);
dir_iter= g_dir_open(dir, 0, &error);
g_print("dir_open succeeded for %s\n", dir);
if (dir_iter) {
while ((file = (gchar *)g_dir_read_name(dir_iter))) {
fullfilename = g_string_new(dir);
fullfilename = g_string_append(fullfilename, "/");
fullfilename = g_string_append(fullfilename, file);
if (g_file_test(fullfilename->str, G_FILE_TEST_IS_DIR)) {
classbrowser_dirlist_add(fullfilename->str);
}
else {
classbrowser_filelist_add(fullfilename->str);
}
g_string_free(fullfilename, TRUE);
}
g_dir_close(dir_iter);
g_print("dir_closed for %s\n", dir);
}
dirlist = g_slist_append(dirlist, dir);
}
--
Andy Jeffries
Technical Director Internet Assist Ltd
Tel : +44 (0)1621 840014 Fax : +44 (0)1621 853959
Web : http://www.i-a.co.uk Email : andy i-a co uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]