[seed: 13/15] Some work on nested directory imports
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed: 13/15] Some work on nested directory imports
- Date: Sun, 12 Apr 2009 02:11:49 -0400 (EDT)
commit 39d0a68c6fcd92a9e31b91056b859dc8465a4e35
Author: Robert Carr <racarr mireia (none)>
Date: Sun Apr 12 01:46:47 2009 -0400
Some work on nested directory imports
---
libseed/seed-importer.c | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index c60fd63..cc84442 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -554,9 +554,11 @@ seed_importer_dir_get_property (JSContextRef ctx,
JSStringRef property_name,
JSValueRef *exception)
{
+ GError *e = NULL;
GDir *dir;
guint len;
- gchar *prop, *dir_path, *entry;
+ const gchar *entry;
+ gchar *dir_path, *prop;
dir_path = JSObjectGetPrivate (object);
@@ -566,7 +568,37 @@ seed_importer_dir_get_property (JSContextRef ctx,
JSStringGetUTF8CString (property_name, prop, len);
// TODO: GError
- dir = g_dir_open (dir_path, 0, NULL);
+ dir = g_dir_open (dir_path, 0, &e);
+ if (e)
+ {
+ seed_make_exception_from_gerror (ctx, exception, e);
+ g_error_free (e);
+
+ return NULL;
+ }
+ while (entry = g_dir_read_name (dir))
+ {
+ gchar *mentry = g_strdup (entry);
+ guint i;
+
+ for (i = 0; i < strlen (mentry); i++)
+ {
+ if (mentry[i] = '.')
+ mentry[i] = '\0';
+ }
+ if (!strcmp (mentry, prop))
+ {
+ JSObjectRef ret;
+
+ ret = seed_importer_handle_file (ctx, dir_path, entry, exception);
+ g_dir_close (dir);
+ g_free (mentry);
+
+ return ret;
+ }
+ g_free (mentry);
+ }
+ g_dir_close (dir);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]