+ char *psz_ignore;
+
+ struct stat_list_t stself;
+#ifndef WIN32
+ int fd = dirfd (handle);
+
+ if ((fd == -1) || fstat (fd, &stself.st))
+ {
+ msg_Err (p_playlist, "cannot stat `%s': %m", psz_name);
+ return VLC_EGENERIC;
+ }
+
+ for (stat_list_t *stats = stparent; stats != NULL; stats = stats->parent)
+ {
+ if ((stself.st.st_ino == stats->st.st_ino)
+ && (stself.st.st_dev == stats->st.st_dev))
+ {
+ msg_Warn (p_playlist,
+ "ignoring infinitely recursive directory `%s'",
+ psz_name);
+ return VLC_SUCCESS;
+ }
+ }
+#else
+ /* Windows has st_dev (driver letter - 'A'), but it zeroes st_ino,
+ * so that the test above will always incorrectly succeed.
+ * Besides, Windows does not have dirfd(). */
+#endif
+
+ stself.parent = stparent;
+
+ /* Get the first directory entry */
+ i_dir_content = utf8_loaddir (handle, &pp_dir_content, NULL, Sort);
+ if( i_dir_content == -1 )
+ {
+ msg_Err (p_playlist, "cannot read `%s': %m", psz_name);
+ return VLC_EGENERIC;
+ }
+ else if( i_dir_content <= 0 )
+ {
+ /* directory is empty */
+ msg_Dbg( p_playlist, "%s directory is empty", psz_name );
+ free( pp_dir_content );
+ return VLC_SUCCESS;
+ }
+
+ /* Build array with ignores */
+ psz_ignore = var_CreateGetString( p_playlist, "ignore-filetypes" );