[vlc-commits] sftp: do not try to open directory as a file
Petri Hintukainen
git at videolan.org
Fri Mar 13 10:37:25 CET 2015
vlc | branch: master | Petri Hintukainen <phintuka at gmail.com> | Fri Mar 13 11:04:48 2015 +0200| [2848264a2ba5077e6b9a78af525148c3b040d459] | committer: Jean-Baptiste Kempf
sftp: do not try to open directory as a file
Usually opening a directory as a file succeeds.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2848264a2ba5077e6b9a78af525148c3b040d459
---
modules/access/sftp.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index b4577ac..a63ca95 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -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" );
More information about the vlc-commits
mailing list