+ /* "Open" the base directory */
+ directory_t *root = malloc (sizeof (*root));
+ if (unlikely(root == NULL))
+ {
+ free (uri);
+ goto error;
+ }
+
+ char *psz_sort = var_InheritString (p_access, "directory-sort");
+ if (!psz_sort)
+ p_sys->compar = collate;
+ else if (!strcasecmp (psz_sort, "version"))
+ p_sys->compar = version;
+ else if (!strcasecmp (psz_sort, "none"))
+ p_sys->compar = NULL;
+ else
+ p_sys->compar = collate;
+ free(psz_sort);
+
+ root->parent = NULL;
+ root->handle = handle;
+ root->uri = uri;
+ root->filec = vlc_loaddir (handle, &root->filev, visible, p_sys->compar);
+ if (root->filec < 0)
+ root->filev = NULL;
+ root->i = 0;
+#ifdef HAVE_OPENAT
+ struct stat st;
+ if (fstat (dirfd (handle), &st))
+ {
+ free (root);
+ free (uri);
+ goto error;
+ }
+ root->device = st.st_dev;
+ root->inode = st.st_ino;
+#else
+ root->path = strdup (p_access->psz_filepath);
+#endif
+