+static gint islink_loop(const gchar *s)
+{
+ gchar *sl;
+ struct stat st;
+ gint ret = FALSE;
+
+ sl = path_from_utf8(s);
+
+ if (lstat(sl, &st) == 0 && S_ISLNK(st.st_mode))
+ {
+ gchar *buf;
+ gint l;
+
+ buf = g_malloc(st.st_size + 1);
+ l = readlink(sl, buf, st.st_size);
+ if (l == st.st_size)
+ {
+ buf[l] = '\0';
+
+ parse_out_relatives(buf);
+ l = strlen(buf);
+
+ parse_out_relatives(sl);
+
+ if (buf[0] == '/')
+ {
+ if (strncmp(sl, buf, l) == 0 &&
+ (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;
+ }
+ else
+ {
+ gchar *link_path;
+
+ link_path = concat_dir_and_file(sl, buf);
+ parse_out_relatives(link_path);
+
+ if (strncmp(sl, link_path, l) == 0 &&
+ (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;
+
+ g_free(link_path);
+ }
+ }
+
+ g_free(buf);
+ }
+
+ g_free(sl);
+
+ return ret;
+}
+
+static gint is_ignored(const gchar *s, gint ignore_symlinks)
+{
+ struct stat st;
+ const gchar *n;
+
+ if (!lstat_utf8(s, &st)) return TRUE;
+
+#if 0
+ /* normal filesystems have directories with some size or block allocation,
+ * special filesystems (like linux /proc) set both to zero.
+ * enable this check if you enable listing the root "/" folder
+ */
+ if (st.st_size == 0 && st.st_blocks == 0) return TRUE;
+#endif
+
+ if (S_ISLNK(st.st_mode) && (ignore_symlinks || islink_loop(s))) return TRUE;
+
+ n = filename_from_path(s);
+ if (n && strcmp(n, GQVIEW_RC_DIR) == 0) return TRUE;
+
+ return FALSE;
+}
+
+static GList *pan_window_layout_list(const gchar *path, SortType sort, gint ascend,
+ gint ignore_symlinks)