+
+#ifdef QUARTZ_RELOCATION
+
+/* Bundle-based functions for various directories. These almost work
+ * even when the application isn't in a bundle, becuase mainBundle
+ * paths point to the bin directory in that case. It's a simple matter
+ * to test for that and remove the last element.
+ */
+
+static const gchar *
+get_bundle_path (void)
+{
+ static gchar *path = NULL;
+
+ if (path == NULL)
+ {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ gchar *resource_path = g_strdup ([[[NSBundle mainBundle] resourcePath] UTF8String]);
+ gchar *base;
+ [pool drain];
+
+ base = g_path_get_basename (resource_path);
+ if (strcmp (base, "bin") == 0)
+ path = g_path_get_dirname (resource_path);
+ else
+ path = strdup (resource_path);
+
+ g_free (resource_path);
+ g_free (base);
+ }
+
+ return path;
+}
+
+const gchar *
+_gtk_get_datadir (void)
+{
+ static gchar *path = NULL;
+
+ if (path == NULL)
+ path = g_build_filename (get_bundle_path (), "share", NULL);
+
+ return path;
+}
+
+const gchar *
+_gtk_get_libdir (void)
+{
+ static gchar *path = NULL;
+
+ if (path == NULL)
+ path = g_build_filename (get_bundle_path (), "lib", NULL);
+
+ return path;
+}
+
+const gchar *
+_gtk_get_localedir (void)
+{
+ static gchar *path = NULL;
+
+ if (path == NULL)
+ path = g_build_filename (get_bundle_path (), "share", "locale", NULL);
+
+ return path;
+}
+
+const gchar *
+_gtk_get_sysconfdir (void)
+{
+ static gchar *path = NULL;
+
+ if (path == NULL)
+ path = g_build_filename (get_bundle_path (), "etc", NULL);
+
+ return path;
+}
+
+const gchar *
+_gtk_get_data_prefix (void)
+{
+ return get_bundle_path ();
+}
+
+#endif /* QUARTZ_RELOCATION */