summaryrefslogtreecommitdiff
path: root/libavformat/libssh.c
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki@gmail.com>2014-01-20 23:59:59 +0100
committerLukasz Marek <lukasz.m.luki@gmail.com>2014-01-22 00:41:13 +0100
commitbf5d73b04d68d878116c36e669b21e5399f7dce4 (patch)
tree1cf0d0b1b6b4c8d9417c79c2b1a8c2d742446e9b /libavformat/libssh.c
parent8d3f14e11b34810fc48b1459ce22ee072c765814 (diff)
lavf/libssh: factorize file_stat function
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavformat/libssh.c')
-rw-r--r--libavformat/libssh.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavformat/libssh.c b/libavformat/libssh.c
index a425c24dfa..3bd581bf66 100644
--- a/libavformat/libssh.c
+++ b/libavformat/libssh.c
@@ -108,6 +108,19 @@ static av_cold int libssh_open_file(LIBSSHContext *libssh, int flags, const char
return 0;
}
+static av_cold void libssh_stat_file(LIBSSHContext *libssh)
+{
+ sftp_attributes stat;
+
+ if (!(stat = sftp_fstat(libssh->file))) {
+ av_log(libssh, AV_LOG_WARNING, "Cannot stat remote file.\n");
+ libssh->filesize = -1;
+ } else {
+ libssh->filesize = stat->size;
+ sftp_attributes_free(stat);
+ }
+}
+
static int libssh_close(URLContext *h)
{
LIBSSHContext *s = h->priv_data;
@@ -131,7 +144,6 @@ static int libssh_open(URLContext *h, const char *url, int flags)
long timeout = s->rw_timeout * 1000;
const char *user = NULL, *pass = NULL;
char *end = NULL;
- sftp_attributes stat;
av_url_split(proto, sizeof(proto),
credencials, sizeof(credencials),
@@ -179,13 +191,7 @@ static int libssh_open(URLContext *h, const char *url, int flags)
if ((ret = libssh_open_file(s, flags, path)) < 0)
goto fail;
- if (!(stat = sftp_fstat(s->file))) {
- av_log(h, AV_LOG_WARNING, "Cannot stat remote file %s.\n", path);
- s->filesize = -1;
- } else {
- s->filesize = stat->size;
- sftp_attributes_free(stat);
- }
+ libssh_stat_file(s);
return 0;