Comment 13 for bug 349707

Revision history for this message
Jason 'vanRijn' Kasper (vr-movingparts) wrote :

Tobias, this is absolutely perfect. Thank you SO much! With your change, I can now access files on my shared hfsplus partition. YAY! =:)

Rémi, is there any chance at all that this could be included in vlc proper? Here's the small diff that Tobias created...

--- ../vlc-1.0.3/modules/access/directory.c 2009-08-09 17:50:57.000000000 -0400
+++ directory.c 2010-01-11 02:42:54.000000000 -0500
@@ -139,6 +133,24 @@ struct access_sys_t
 static block_t *Block( access_t * );
 static int Control( access_t *, int, va_list );

+static DIR *TryToOpendir(const char *path)
+{
+ DIR *retval = NULL;
+ FILE *file = utf8_fopen(path, "r");
+
+ if(file == NULL) {
+ return NULL;
+ }
+
+ struct stat buf;
+ fstat (fileno (file), &buf);
+ if(S_ISDIR(buf.st_mode)) {
+ retval = utf8_opendir(path);
+ }
+
+ return retval;
+}
+
 /*****************************************************************************
  * Open: open the directory
  *****************************************************************************/
@@ -152,7 +164,9 @@ static int Open( vlc_object_t *p_this )

     DIR *handle;
     if (strcmp (p_access->psz_path, "-"))
- handle = utf8_opendir (p_access->psz_path);
+ {
+ handle = TryToOpendir (p_access->psz_path);
+ }
     else
     {
 #if 0 /* This won't work yet, it generates paths like "-/music.ogg".
@@ -348,7 +362,7 @@ static block_t *Block (access_t *p_acces
         }
         sprintf (sub->path, "%s/%s", current->path, entry);

- DIR *handle = utf8_opendir (sub->path);
+ DIR *handle = TryToOpendir(sub->path);
         if (handle != NULL)
         {
             sub->parent = current;