]> git.sesse.net Git - vlc/commitdiff
sftp: do not try to open directory as a file
authorPetri Hintukainen <phintuka@gmail.com>
Fri, 13 Mar 2015 09:04:48 +0000 (11:04 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 13 Mar 2015 09:34:42 +0000 (10:34 +0100)
Usually opening a directory as a file succeeds.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/access/sftp.c

index b4577ac939a5b53180eac92afc80a7e8ec56533f..a63ca95f95c5b0d29f4a6e2c6d43676251679889 100644 (file)
@@ -225,14 +225,6 @@ static int Open( vlc_object_t* p_this )
         goto error;
     }
 
-    /* Open the given file */
-    p_sys->file = libssh2_sftp_open( p_sys->sftp_session, url.psz_path, LIBSSH2_FXF_READ, 0 );
-    if( !p_sys->file )
-    {
-        msg_Err( p_access, "Unable to open the remote file %s", url.psz_path );
-        goto error;
-    }
-
     /* Get some information */
     LIBSSH2_SFTP_ATTRIBUTES attributes;
     if( libssh2_sftp_stat( p_sys->sftp_session, url.psz_path, &attributes ) )
@@ -240,7 +232,19 @@ static int Open( vlc_object_t* p_this )
         msg_Err( p_access, "Impossible to get information about the remote file %s", url.psz_path );
         goto error;
     }
-    p_sys->filesize = attributes.filesize;
+
+    if( !LIBSSH2_SFTP_S_ISDIR( attributes.permissions ))
+    {
+        /* Open the given file */
+        p_sys->file = libssh2_sftp_open( p_sys->sftp_session, url.psz_path, LIBSSH2_FXF_READ, 0 );
+        p_sys->filesize = attributes.filesize;
+    }
+
+    if( !p_sys->file )
+    {
+        msg_Err( p_access, "Unable to open the remote path %s", url.psz_path );
+        goto error;
+    }
 
     p_sys->i_read_size = var_InheritInteger( p_access, "sftp-readsize" );